akazmi commited on
Commit
887e6fa
·
verified ·
1 Parent(s): b9be122

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -15
app.py CHANGED
@@ -8,20 +8,30 @@ st.title('Sales Data Visualization App')
8
  # Display Sample Data Format
9
  st.subheader('Sample Data Format:')
10
  st.write("""
11
- The data should contain the following columns:
12
-
13
- | Customer Name | Date | Product Name | Net Sales Value | Margin Amount | Cost |
14
- |----------------|------------|--------------|------------------|---------------|-------|
15
- | John Doe | 2024-01-01 | Product A | 1000 | 300 | 700 |
16
- | Jane Smith | 2024-01-02 | Product B | 1500 | 400 | 1100 |
17
-
18
- ### Key Columns:
19
- - **Customer Name**: Name of the customer
20
- - **Date**: Sale date (YYYY-MM-DD)
21
- - **Product Name**: Product sold
22
- - **Net Sales Value**: Sales value of the product
23
- - **Margin Amount**: Profit margin on the sale
24
- - **Cost**: Cost of the product sold
 
 
 
 
 
 
 
 
 
 
25
  """)
26
 
27
  # Upload File
@@ -76,8 +86,15 @@ if uploaded_file:
76
  st.write(f"Filtered Data: {len(filtered_df)} records found.")
77
  st.dataframe(filtered_df)
78
 
79
- # Visualizations
80
  if not filtered_df.empty:
 
 
 
 
 
 
 
81
  st.subheader("Sales Trend Over Time")
82
  trend = filtered_df.groupby('Date')['Net Sales Value'].sum().reset_index()
83
  fig_trend = px.line(trend, x='Date', y='Net Sales Value', title='Sales Over Time')
 
8
  # Display Sample Data Format
9
  st.subheader('Sample Data Format:')
10
  st.write("""
11
+ The data should be in the following format with the listed columns:
12
+
13
+ | Customer Name | Date | City | Country | State | Product Name | Product Attribute 1 | Product Attribute 2 | Product Attribute 3 | Product Attribute 4 | Net Sales Value | Margin Amount | Cost |
14
+ |----------------|------------|--------------|-------------|-------------|-----------------|---------------------|---------------------|---------------------|---------------------|------------------|---------------|-------|
15
+ | John Doe | 2024-01-01 | New York | USA | NY | Product A | Attribute 1A | Attribute 2A | Attribute 3A | Attribute 4A | 1000 | 300 | 700 |
16
+ | Jane Smith | 2024-01-02 | Los Angeles | USA | CA | Product B | Attribute 1B | Attribute 2B | Attribute 3B | Attribute 4B | 1500 | 400 | 1100 |
17
+ | Bob Johnson | 2024-02-15 | Chicago | USA | IL | Product A | Attribute 1A | Attribute 2A | Attribute 3A | Attribute 4A | 1200 | 350 | 850 |
18
+ | Alice Williams | 2024-03-10 | Miami | USA | FL | Product C | Attribute 1C | Attribute 2C | Attribute 3C | Attribute 4C | 2000 | 500 | 1500 |
19
+ | Charlie Brown | 2024-04-05 | Houston | USA | TX | Product B | Attribute 1B | Attribute 2B | Attribute 3B | Attribute 4B | 1800 | 450 | 1350 |
20
+
21
+ ### Description of Columns:
22
+ - **Customer Name**: The name of the customer (e.g., John Doe).
23
+ - **Date**: The date of the sale, formatted as `YYYY-MM-DD` (e.g., `2024-01-01`).
24
+ - **City**: The city where the sale took place (e.g., New York).
25
+ - **Country**: The country where the sale took place (e.g., USA).
26
+ - **State**: The state where the sale took place (e.g., NY).
27
+ - **Product Name**: The name of the product (e.g., Product A).
28
+ - **Product Attribute 1**: Additional product attribute (e.g., Attribute 1A).
29
+ - **Product Attribute 2**: Additional product attribute (e.g., Attribute 2A).
30
+ - **Product Attribute 3**: Additional product attribute (e.g., Attribute 3A).
31
+ - **Product Attribute 4**: Additional product attribute (e.g., Attribute 4A).
32
+ - **Net Sales Value**: The net sales value for the transaction (e.g., `1000`).
33
+ - **Margin Amount**: The margin for the transaction (e.g., `300`).
34
+ - **Cost**: The cost of the product sold (e.g., `700`).
35
  """)
36
 
37
  # Upload File
 
86
  st.write(f"Filtered Data: {len(filtered_df)} records found.")
87
  st.dataframe(filtered_df)
88
 
89
+ # Key Metrics: High Margin Product and Highest Sales Month
90
  if not filtered_df.empty:
91
+ st.subheader("Key Metrics")
92
+ high_margin_product = filtered_df.loc[filtered_df['Margin Amount'].idxmax(), 'Product Name']
93
+ highest_sales_month = filtered_df.loc[filtered_df['Net Sales Value'].idxmax(), 'Month']
94
+ st.metric("High Margin Product", high_margin_product)
95
+ st.metric("Highest Sales Month", highest_sales_month)
96
+
97
+ # Visualizations
98
  st.subheader("Sales Trend Over Time")
99
  trend = filtered_df.groupby('Date')['Net Sales Value'].sum().reset_index()
100
  fig_trend = px.line(trend, x='Date', y='Net Sales Value', title='Sales Over Time')