Saif-bio commited on
Commit
862cf89
·
verified ·
1 Parent(s): 3870f73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -38,21 +38,24 @@ def app():
38
 
39
  fig, ax = plt.subplots()
40
 
41
- if "Top Selling" in plot["title"]:
42
- sns.countplot(data=df, x=plot["x"], ax=plot["top"])
43
- if "Category and Time of the Day" in plot["title"]:
44
- sns.countplot(data=df, x=plot["x"], hue=plot["hue"])
45
- if "Size and Time of the Day" in plot["title"]:
46
- sns.countplot(data=df, x=plot["x"], hue=plot["hue"])
47
- if "Revenue" in plot["title"]:
48
- sns.countplot(data=df, x=plot["x"], ax=plot["top"], hue=plot["hue"], estimator=plot["estimator"], marker=plot["marker"])
 
49
 
 
 
 
50
  else:
51
- ax.set_ylabel("quantity")
52
- ax.legend(bbox_to_anchor=(1,1))
53
-
54
  st.pyplot(fig)
55
- plt.show()
56
 
57
  if __name__ == "__main__":
58
  app()
 
38
 
39
  fig, ax = plt.subplots()
40
 
41
+ if "Top Selling Pizzas" in plot["title"]:
42
+ data_aux = df.groupby(plot["x"])[plot["y"]].sum().reset_index().sort_values(by=plot["y"], ascending=False).head(plot["top"])
43
+ ax.bar(data_aux[plot["x"]].values.tolist(), data_aux[plot["y"]].values.tolist())
44
+
45
+ if "Quantity of Pizzas" in plot["title"]:
46
+ sns.countplot(data=df, x=plot["x"], hue=plot["hue"], ax=ax)
47
+
48
+ if "Monthly Revenue" in plot["title"]:
49
+ sns.lineplot(data=df, x=plot["x"], y=plot["y"], hue=plot["hue"], estimator=plot["estimator"], errorbar=None, marker=plot["marker"], ax=ax)
50
 
51
+ ax.set_xlabel(" ".join(plot["x"].split("_")).capitalize())
52
+ if "y" in plot.keys():
53
+ ax.set_ylabel(" ".join(plot["y"].split("_")).capitalize())
54
  else:
55
+ ax.set_ylabel("Quantity")
56
+ ax.legend(bbox_to_anchor=(1,1))
57
+
58
  st.pyplot(fig)
 
59
 
60
  if __name__ == "__main__":
61
  app()