Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import matplotlib.pyplot as plt
- import calendar
- df = pd.read_csv("health.csv", header = None, names = ['Physical', 'Emotional'])
- # Get Dayofweek index number (start with 6 for sunday) 6,0,1....
- df['DayOfTheWeek'] = [(i+6) % 7 for i in range(len(df))]
- # Get a map to translate to day of week
- d = dict(zip(range(7),list(calendar.day_name)))
- df['DayOfTheWeek'] = df['DayOfTheWeek'].map(d)
- # Loop through the df (splitting week by week)
- for i in range(int(round(len(df)/7))):
- plt.ylim([0,10])
- df.iloc[i*7:(i+1)*7].set_index('DayOfTheWeek').plot(kind='bar')
- plt.show()
Add Comment
Please, Sign In to add comment