urschrei
urschrei

Reputation: 26859

Plotting grouped data by date

I'm trying to plot the counts of some pandas dataframe columns, grouped by date:

by_date = data.groupby(data.index.day).count()

result

The data are correct, but the the data.index.day I specified is no good for plotting purposes:

enter image description here

Is there a way of specifying that I want to group by Python Date objects, or am I doing this completely wrong?

Update: Dan Allan's resample suggestion worked, but now the the xticks are unreadable. Should I be extracting them separately?

enter image description here

Upvotes: 2

Views: 227

Answers (1)

Dan Allan
Dan Allan

Reputation: 35235

I think this task is more easily accomplished using resample, not group. How about

data.resample('D', how='count')

Upvotes: 1

Related Questions