I have a DataFrame with a two-level MultiIndex. The first level date
is a DatetimeIndex and the second level name
is just some strings. The data has 10-minute intervals.
How can I group by date on the first level of this MultiIndex and count the number of rows I have per day?
I suspect that the DatetimeIndex coupled into a MultiIndex is giving me problems, since doing
data.groupby(pd.TimeGrouper(freq='D')).count()
gives me
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'MultiIndex'
I've also tried writing
data.groupby(data.index.levels[0].date).count()
which leads to
ValueError: Grouper and axis must be same length
How could I, for example, make the grouper longer (i.e., include duplicate index values, omitting of which now make it shorter than the axis)?
Thanks!