Guest User

Untitled

a guest
Nov 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3. import calendar
  4.  
  5. df = pd.read_csv("health.csv", header = None, names = ['Physical', 'Emotional'])
  6. # Get Dayofweek index number (start with 6 for sunday) 6,0,1....
  7. df['DayOfTheWeek'] = [(i+6) % 7 for i in range(len(df))]
  8.  
  9. # Get a map to translate to day of week
  10. d = dict(zip(range(7),list(calendar.day_name)))
  11. df['DayOfTheWeek'] = df['DayOfTheWeek'].map(d)
  12.  
  13. # Loop through the df (splitting week by week)
  14. for i in range(int(round(len(df)/7))):
  15. plt.ylim([0,10])
  16. df.iloc[i*7:(i+1)*7].set_index('DayOfTheWeek').plot(kind='bar')
  17. plt.show()
Add Comment
Please, Sign In to add comment