File size: 1,803 Bytes
acde077
 
 
bfa05e4
16e1a4d
 
71d9b5d
16e1a4d
 
 
acde077
 
16e1a4d
 
 
 
 
 
 
acde077
16e1a4d
 
acde077
16e1a4d
 
5bfd7f9
16e1a4d
5bfd7f9
16e1a4d
 
 
 
 
 
 
 
9b8ea08
 
 
 
 
16e1a4d
9b8ea08
16e1a4d
 
 
 
5bfd7f9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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()