Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| st.set_option('deprecation.showPyplotGlobalUse', False) | |
| # Load the monthly and yearly CSV data | |
| monthly_file_path = "important5years.csv" | |
| yearly_file_path = "Till_now.csv" | |
| df_monthly = pd.read_csv(monthly_file_path) | |
| df_yearly = pd.read_csv(yearly_file_path) | |
| # Streamlit app | |
| st.title("GENERICART SALES TREND") | |
| # Dropdown for selecting an index (Shop Code) | |
| selected_index = st.selectbox("Select Shop Code:", df_monthly["Shop Code"].unique()) | |
| # Dropdown for selecting data type | |
| selected_data_type = st.selectbox("Select Data Type:", ["Monthly", "Yearly"]) | |
| # Plotting | |
| if st.button("Submit"): | |
| if selected_data_type == "Monthly": | |
| df_selected = df_monthly[df_monthly["Shop Code"] == selected_index] | |
| df_selected = df_selected.astype(str) # Convert to string | |
| plt.figure(figsize=(10, 6)) | |
| plt.bar(df_selected.columns[1:], df_selected.iloc[0, 1:].astype(float)) | |
| plt.title(f"Monthly Sales Data for Shop Code {selected_index}") | |
| plt.xlabel("Months") | |
| plt.ylabel("Sales Amount") | |
| plt.xticks(rotation=90, ha="right") | |
| st.pyplot() | |
| elif selected_data_type == "Yearly": | |
| df_selected = df_yearly[df_yearly["Shop Code"] == selected_index] | |
| # Filter out non-numeric columns | |
| numeric_columns = df_selected.columns[1:] | |
| df_selected[numeric_columns] = df_selected[numeric_columns].apply(pd.to_numeric, errors='coerce') | |
| plt.figure(figsize=(10, 6)) | |
| plt.bar(numeric_columns, df_selected.iloc[0, 1:].astype(float)) | |
| plt.title(f"Yearly Sales Data for Shop Code {selected_index}") | |
| plt.xlabel("Years") | |
| plt.ylabel("Sales Amount") | |
| plt.xticks(rotation=90, ha="right") | |
| st.pyplot() |