Spaces:
Build error
Build error
Update app.py
Browse files1 unmodified line23456797 unmodified lines105106107108109110111121 unmodified lines2332342351 unmodified lineimport pandas as pdfrom datetime import datetimeimport osfrom huggingface_hub import HfApi, upload_file, list_repo_files, hf_hub_download# Configuration for Hugging Face Repository97 unmodified linesst.session_state.current_selections = load_current_selections().to_dict(orient="records")# Sidebar for navigating through different viewsmenu = st.sidebar.selectbox("Select View", ["Poll", "Current", "History"])# Function to reset the current selections after submissiondef reset_selections():121 unmodified linesst.table(record["Summary"])else:st.write("No history records found.")1 unmodified line2345678997 unmodified lines107108109110111112113121 unmodified lines2352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732741 unmodified lineimport pandas as pdfrom datetime import datetimeimport osimport matplotlib.pyplot as pltimport seaborn as snsfrom huggingface_hub import HfApi, upload_file, list_repo_files, hf_hub_download# Configuration for Hugging Face Repository97 unmodified linesst.session_state.current_selections = load_current_selections().to_dict(orient="records")# Sidebar for navigating through different viewsmenu = st.sidebar.selectbox("Select View", ["Poll", "Current", "History", "Graph"])# Function to reset the current selections after submissiondef reset_selections():121 unmodified linesst.table(record["Summary"])else:st.write("No history records found.")# Graph view to display a line chart of item selections over timeelif menu == "Graph":st.title("Breakfast Poll History - Graph View")# Prepare data for plottingif st.session_state.history:history_data = []for record in st.session_state.history:date = record['Date']for index, row in record['Summary'].iterrows():for drink in row['Drinks'].split(', '):history_data.append({'Date': date, 'Item': drink, 'Type': 'Drink'})for food in row['Food'].split(', '):history_data.append({'Date': date, 'Item': food, 'Type': 'Food'})# Create a DataFrame from history datahistory_df = pd.DataFrame(history_data)# Count occurrences of each item per dateitem_counts = history_df.groupby(['Date', 'Item']).size().reset_index(name='Count')# Create a line plot for each item over timeplt.figure(figsize=(12, 6))sns.lineplot(data=item_counts, x='Date', y='Count', hue='Item', marker='o')# Customize the plotplt.xticks(rotation=45)plt.title('Item Selections Over Time')plt.xlabel('Date')plt.ylabel('Number of Selections')plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.15), ncol=3)# Display the plotst.pyplot(plt.gcf())else:st.write("No historical data available to plot.")
app.py+40-1