Advertisement
elena1234

boxplot and histogram of the tips grouped by the day

May 5th, 2022 (edited)
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. # Create a boxplot of the tips grouped by the day
  2. time_groups = tips_data.groupby(['day'])
  3. sun_time = time_groups.get_group('Sun')
  4. sat_time = time_groups.get_group('Sat')
  5. thur_time = time_groups.get_group('Thur')
  6. fri_time = time_groups.get_group('Fri')
  7.  
  8. col1 = sun_time['tip']
  9. col2 = sat_time['tip']
  10. col3 = thur_time['tip']
  11. col4 = fri_time['tip']
  12. DF = pd.DataFrame({'sunday': col1, 'saturday': col2, 'thursday' : col3, 'friday': col4})
  13. ax = DF[['sunday', 'saturday', 'thursday', 'friday']].plot(kind='box', title='boxplot', showmeans=True)
  14. plt.show()
  15.  
  16. # Create a histogram of the tips grouped by the day
  17. g = sns.FacetGrid(tips_data, row = 'day')
  18. g = g.map(plt.hist, 'tip')
  19.  
  20. ################################################################
  21. '''
  22. bp = sns.boxplot(data=da.loc[:, ["BPXSY1", "BPXSY2", "BPXDI1", "BPXDI2"]])
  23. bp.set_ylabel("Blood pressure in mm/Hg")
  24. '''
  25.  
  26. #################################################################
  27. sns.boxplot(x = df['Branch'], y = df['gross income'])
  28.  
  29. plt.boxplot([op1["Length"], op2["Length"]])
  30. plt.xlabel("Op-1 and Op-2")
  31. plt.ylabel("Length in mm")
  32. plt.title("Plot Length in Op-1 and Op-2")
  33. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement