Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,42 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import matplotlib.pyplot as plt
|
| 4 |
-
import numpy as np
|
| 5 |
|
| 6 |
-
# Load the CSV data
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Streamlit app
|
| 12 |
-
st.title("
|
| 13 |
-
|
| 14 |
-
# Dropdown for selecting an index
|
| 15 |
-
selected_index = st.selectbox("Select
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
| 18 |
if st.button("Submit"):
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import matplotlib.pyplot as plt
|
|
|
|
| 4 |
|
| 5 |
+
# Load the monthly and yearly CSV data
|
| 6 |
+
monthly_file_path = "important5years.csv"
|
| 7 |
+
yearly_file_path = "important-Yearwise-5years.csv"
|
| 8 |
+
|
| 9 |
+
df_monthly = pd.read_csv(monthly_file_path)
|
| 10 |
+
df_yearly = pd.read_csv(yearly_file_path)
|
| 11 |
|
| 12 |
# Streamlit app
|
| 13 |
+
st.title("GENERICART SALES TREND")
|
| 14 |
+
|
| 15 |
+
# Dropdown for selecting an index (Shop Code)
|
| 16 |
+
selected_index = st.selectbox("Select Shop Code:", df_monthly["Shop Code"].unique())
|
| 17 |
+
|
| 18 |
+
# Dropdown for selecting data type
|
| 19 |
+
selected_data_type = st.selectbox("Select Data Type:", ["Monthly", "Yearly"])
|
| 20 |
|
| 21 |
+
|
| 22 |
+
# Plotting
|
| 23 |
if st.button("Submit"):
|
| 24 |
+
if selected_data_type == "Monthly":
|
| 25 |
+
df_selected = df_monthly[df_monthly["Shop Code"] == selected_index]
|
| 26 |
+
plt.figure(figsize=(10, 6))
|
| 27 |
+
plt.bar(df_selected.columns[1:], df_selected.iloc[0, 1:])
|
| 28 |
+
plt.title(f"Monthly Sales Data for Shop Code {selected_index}")
|
| 29 |
+
plt.xlabel("Months")
|
| 30 |
+
plt.ylabel("Sales Amount")
|
| 31 |
+
plt.xticks(rotation=90, ha="right")
|
| 32 |
+
st.pyplot()
|
| 33 |
+
|
| 34 |
+
elif selected_data_type == "Yearly":
|
| 35 |
+
df_selected = df_yearly[df_yearly["Shop Code"] == selected_index]
|
| 36 |
+
plt.figure(figsize=(10, 6))
|
| 37 |
+
plt.bar(df_selected.columns[1:], df_selected.iloc[0, 1:])
|
| 38 |
+
plt.title(f"Yearly Sales Data for Shop Code {selected_index}")
|
| 39 |
+
plt.xlabel("Years")
|
| 40 |
+
plt.ylabel("Sales Amount")
|
| 41 |
+
plt.xticks(rotation=90, ha="right")
|
| 42 |
+
st.pyplot()
|