I have a dataframe that looks like this:
type date count CLASS
A jan 456 0
A feb 121 1
A mar 333 1
B apr 123 1
B may 123 1
C jun 189 1
C jul 789 1
I would like to create a scatter plot of the counts of type 'A' over time (date), so I would need to use the type, date, and count columns.
I would like to do something like this, but I'm not sure how to incorporate the counts column?
group = df.groupby('Type' == 'A')
df.plot.scatter(x = 'Year_Month', y = group)
plt.legend()
plt.show()
I also get a key error when I try this ^
Basically, the scatter plot should plot the counts of type A over time.
Thank you.
CodePudding user response:
Try this:
df[df['type']=='A'].plot.scatter('date', 'count')
Since you only want the data where type is A
you don't need a groupby here.