Spaces:
Build error
Build error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -34,28 +34,30 @@ def app():
|
|
| 34 |
st.sidebar.metric("Repeat Customers", repeat_customers)
|
| 35 |
|
| 36 |
plots = [
|
| 37 |
-
{"title": "Top
|
| 38 |
-
{"title": "
|
| 39 |
-
{"title": "
|
| 40 |
-
{"title": "Monthly Revenue", "x": "order_month", "y": "total_price"}
|
| 41 |
]
|
| 42 |
|
| 43 |
for plot in plots:
|
| 44 |
st.header(plot["title"])
|
| 45 |
-
|
| 46 |
-
data = getattr(df[plot["x"]], plot["agg"])().sort_values(ascending=False)
|
| 47 |
-
else:
|
| 48 |
-
data = df.groupby(plot["x"])[plot["y"]].sum().sort_values(ascending=False)
|
| 49 |
-
if "top" in plot:
|
| 50 |
-
data = data.head(plot["top"])
|
| 51 |
fig, ax = plt.subplots()
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
ax.set_xlabel(plot["x"].capitalize())
|
| 56 |
ax.set_ylabel(plot["y"].capitalize())
|
| 57 |
-
|
| 58 |
-
ax.set_xlabel("Month")
|
| 59 |
st.pyplot(fig)
|
| 60 |
|
| 61 |
|
|
|
|
| 34 |
st.sidebar.metric("Repeat Customers", repeat_customers)
|
| 35 |
|
| 36 |
plots = [
|
| 37 |
+
{"title": "Top Selling Pizzas (by Quantity)", "x": "pizza_name", "y": "quantity", "top": 5},
|
| 38 |
+
{"title": "Quantity of Pizzas Sold by Category and Time of the Day", "x": "time_of_day", "hue": "pizza_category"},
|
| 39 |
+
{"title": "Quantity of Pizzas Sold by Size and Time of the Day", "x": "time_of_day", "hue": "pizza_size"},
|
| 40 |
+
{"title": "Monthly Revenue Trends by Pizza Category", "x": "order_month", "y": "total_price", "hue": "pizza_category", "estimator": "sum", "marker": "o"},
|
| 41 |
]
|
| 42 |
|
| 43 |
for plot in plots:
|
| 44 |
st.header(plot["title"])
|
| 45 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
fig, ax = plt.subplots()
|
| 47 |
+
|
| 48 |
+
if "top" in plot["title"]:
|
| 49 |
+
data = df.groupby(plot["x"]).quantity.sum().reset_index().sort_values(by="quantity", ascending=False).head()
|
| 50 |
+
sns.countplot(x=plot["x"], data=data, ax=ax)
|
| 51 |
+
|
| 52 |
+
if "Quantity" in plot["title"]:
|
| 53 |
+
sns.countplot(x=plot["x"], hue=plot["hue"], data=df, ax=ax)
|
| 54 |
+
|
| 55 |
+
if "Revenue" in plot["title"]:
|
| 56 |
+
sns.lineplot(x=plot["x"], y=plot["y"], hue=plot["hue"], data=df, estimator=plot["estimator"], marker=plot["marker"], ax=ax)
|
| 57 |
+
|
| 58 |
ax.set_xlabel(plot["x"].capitalize())
|
| 59 |
ax.set_ylabel(plot["y"].capitalize())
|
| 60 |
+
|
|
|
|
| 61 |
st.pyplot(fig)
|
| 62 |
|
| 63 |
|