Reputation: 25
https://i.sstatic.net/F0Slf.png
How do I plot the Date(x-axis) against the Target(y-axis)(the number of occurrences in that date? I want the 'Date' to be like a timeline kind of graph which has like 2020-01 , 2020-02 and so on
Upvotes: 0
Views: 90
Reputation: 4554
I think this should do:
df.index = pd.to_datetime(df.index,format = '%d/%m/%Y')
fig,ax = plt.subplots(figsize=(10,6))
ax.plot(df.index.strftime('%Y-%m-%d'),df['target'],'o')
# If you don't want day, just put '%Y-%m'
# Rotate xticks
plt.gcf().autofmt_xdate()
plt.show()
Upvotes: 1