Project Brief
Today’s task is to create a data dashboard web app using Streamliot that allows the users to:
Upload and view a CSV file on the dashboard
Select any field of the CSV file to plot
Expected Output
Here is how the web app should look and behave:
Environment Setup Instructions
Install the required libraries with:
pip install streamlit pandas
Execute with streamlit run main.py
Project Solution
Feel free to post your questions or comments in the comment section below.
Happy Coding!
Daily Python Projects Team
I've done. Here is my code:
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
# Title of the app
st.title('Data Dashboard')
# file uploader
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
if uploaded_file is not None:
# Read the csv file
df = pd.read_csv(uploaded_file)
# Display the DataFrame
st.write(df)
# Select field for plotting
fields = df.columns.tolist()
details_plot = st.selectbox('Select a column to plot', fields)
st.write(f"Plotting column {details_plot}:")
if details_plot:
# Plotting
fig, ax = plt.subplots()
ax.plot(df[details_plot])
st.pyplot(fig)