streamlit visualize upload multi-sheet data
To visualize multi-sheet data uploaded to Streamlit, you can use the pandas library to read the Excel file and extract each sheet as a separate DataFrame. Then, you can use any visualization library of your choice to create the visualization.
Here's an example of how to create a dropdown menu in Streamlit to select the sheet to visualize:
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
# Upload the Excel file
uploaded_file = st.file_uploader("Choose an Excel file", type="xlsx")
if uploaded_file is not None:
# Read the Excel file
excel_data = pd.read_excel(uploaded_file, sheet_name=None)
# Create a dropdown menu to select the sheet to visualize
sheet_name = st.selectbox("Select a sheet", list(excel_data.keys()))
# Extract the selected sheet as a DataFrame
df = excel_data[sheet_name]
# Visualize the DataFrame using matplotlib
fig, ax = plt.subplots()
ax.plot(df["Date"], df["Value"])
ax.set_xlabel("Date")
ax.set_ylabel("Value")
st.pyplot(fig)
In this example, the user can upload an Excel file and select a sheet from a dropdown menu. The selected sheet is extracted as a DataFrame and visualized using matplotlib. You can modify the visualization code to use any other library of your choice
原文地址: http://www.cveoy.top/t/topic/fc1K 著作权归作者所有。请勿转载和采集!