I am new to streamlit
I have been given a task
“Develop a dashboard app with streamlit using plotly to visualize the workers population of
various industries with respect to various geographies and Analyze some Facts and Figures for
the Business Problem”
I cannot understand where to begin
this is not a homework or school assignment
it is a self evaluation task
kindly help me in showing the steps to build the APP
Have a look on the documentation. Come back and post if you have something to ask or comment.
In the documentation, search quickly what you want.
Hi @kreety_kishore it seems that you should start from some tutorials
Let’s see what Chat GTP has to say about solving your task:
To solve this task, follow these steps:
- Familiarize yourself with both Streamlit and Plotly libraries.
- Collect or generate data on the workers population in various industries and geographies.
- Use Streamlit to build the dashboard app, incorporating Plotly for visualization.
- Create interactive visualizations, such as bar charts or scatter plots, to show the workers population data.
- Write code to present these insights on the dashboard in a clear and concise manner.
- Test the app and make any necessary improvements.
You may also want to consider adding additional features, such as filters or dropdown menus, to allow for more in-depth analysis and customization of the data.
For me, sounds like a plan
The chatgpt can actually generate code with streamlit and plotly.
Prompt: Create a python code that uses streamlit that plots using plotly from a dataframe
Here’s a code that uses streamlit and plotly to plot a line chart from a pandas dataframe:
import streamlit as st import pandas as pd import plotly.express as px @st.cache def load_data(): return pd.read_csv("https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv") df = load_data() st.title("Air Travel Time Series Plot") st.write("This chart shows the number of air passenger traveled in each month from 1949 to 1960") fig = px.line(df, x="Month", y="Passengers", title="Air Passenger Travel") st.plotly_chart(fig)
In this code, we first load a csv file containing the data into a pandas dataframe. The
st.cache decorator is used to cache the dataframe, so it’s only loaded once when the app starts.
Next, we use
st.title to set the title of the page and
st.write to write some additional information about the chart.
Finally, we use
plotly.express.line to create a line chart from the dataframe and pass the chart to
st.plotly_chart to display it on the page.
There was one error though. the y value. I fixed that one line and set y to the rest of the columns.
fig = px.line(df, x="Month", y=df.columns[1:], title="Air Passenger Travel")
After that streamlit is ok.
The 1949 is also wrong, perhaps the csv has been updated, but overall it is almost there.
Studying the documentation is always better.
Thanks @ferdy for pointint that out! I’m still amazed that this is possible