Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = {datetime.date(2018, 1, 26): 1, datetime.date(2018, 1, 18): 1, datetime.date(2018, 1, 11): 4, datetime.date(2017, 12, 31): 2, datetime.date(2018, 1, 14): 1, datetime.date(2018, 1, 9): 2, datetime.date(2018, 1, 7): 1, datetime.date(2018, 1, 16): 2, datetime.date(2018, 1, 15): 2, datetime.date(2018, 1, 10): 1, datetime.date(2018, 1, 5): 1, datetime.date(2018, 1, 13): 3}
- dates = pd.date_range('2018-01-01', date.today())
- data = pd.Series(data=data)
- data = data.reindex(dates, fill_value=0)
- fig, ax = plt.subplots(figsize=(15, 7))
- data.plot(kind='bar', ax=ax)
- plt.xticks(rotation=45)
- plt.gca().xaxis.set_major_formatter(plt.FixedFormatter(data.index.to_series().dt.strftime("%b %d")))
- data = <my dictionary>
- dates = pd.date_range('2018-01-01', date.today())
- data = pd.Series(data=data)
- data = data.fillna(0, inplace=True)
- fig, ax = plt.subplots(figsize=(15, 7))
- data.plot(kind='bar', ax=ax)
- plt.xticks(rotation=45)
- plt.gca().xaxis.set_major_formatter(plt.FixedFormatter(data.index.to_series().dt.strftime("%b %d")))
Add Comment
Please, Sign In to add comment