Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -56,8 +56,8 @@ def calculate_kpis(df):
|
|
| 56 |
else:
|
| 57 |
top_five_product = "there are less than 5 products in this dataset"
|
| 58 |
|
| 59 |
-
if df['
|
| 60 |
-
best_branch = df.groupby('
|
| 61 |
else:
|
| 62 |
best_branch = "there is only one branch in this dataset"
|
| 63 |
|
|
@@ -66,7 +66,7 @@ def calculate_kpis(df):
|
|
| 66 |
|
| 67 |
# Calculate Customer Purchase Frequency (Requires more data for accurate calculation)
|
| 68 |
# Assuming 'Member Card No_' is a unique identifier for customers
|
| 69 |
-
customer_purchase_frequency = df.groupby('
|
| 70 |
|
| 71 |
# Calculate Estimated Customer Lifetime Value (CLTV) (Requires more data for accurate calculation)
|
| 72 |
# Assuming a simple CLTV model based on AOV and purchase frequency
|
|
|
|
| 56 |
else:
|
| 57 |
top_five_product = "there are less than 5 products in this dataset"
|
| 58 |
|
| 59 |
+
if df['Branch_Name'].nunique() > 1:
|
| 60 |
+
best_branch = df.groupby('Branch_Name')['Price'].sum().nlargest(1).index.tolist()
|
| 61 |
else:
|
| 62 |
best_branch = "there is only one branch in this dataset"
|
| 63 |
|
|
|
|
| 66 |
|
| 67 |
# Calculate Customer Purchase Frequency (Requires more data for accurate calculation)
|
| 68 |
# Assuming 'Member Card No_' is a unique identifier for customers
|
| 69 |
+
customer_purchase_frequency = df.groupby('Customer_Name')['Receipt No_'].nunique().mean()
|
| 70 |
|
| 71 |
# Calculate Estimated Customer Lifetime Value (CLTV) (Requires more data for accurate calculation)
|
| 72 |
# Assuming a simple CLTV model based on AOV and purchase frequency
|