Python Streamlit Unit1

 Python Streamlit Unit1

In this mini project we will be using streamlit a python framework to build a simple web portfolio and to also analyse data

skills required: pandas, streamlit, python, seaborn, scikitlearn etc

PHASE 1: Setting up the menu bars for the Dashboard

#import package
import streamlit as st
import streamlit.components.v1 as stc

#import data analysis
import pandas as pd

def main_menu():
st.title("ABC Portfolio")

dashboard = ["Home", "Services", "About"]
choice = st.sidebar.selectbox("My Dashboard", dashboard)

if choice == "Home":
st.subheader("Home")

elif choice == "Services":
st.subheader("Our Services")

else:
st.subheader("About")
st.text("Fantastic work with Python Streamlit")

if __name__ == '__main__':
main_menu()

OUTPUT (SCREENSHOT)
NB: You can click the hamburger icon to expand and collapse the sidebar menus

Phase 2 - Data caching

@st.cache
def get_data():
    url = "http://data.insideairbnb.com/united-states/ny/new-york-city/2019-09-12/visualisations/listings.csv"
    return pd.read_csv(url)
df = get_data()

Data caching
The st.cache decorator indicates that Streamlit will perform internal magic so that the data will be downloaded only once and cached for future use.


Comments

Popular posts from this blog

Basic Web Page - phase 1