0

I'm trying to create frequency table from some dates by pandas TimeGrouper but I receive the following error

input:

t = pd.to_datetime(t)

t = pd.Series(t)

t

output:

0   2019-04-10 10:49:00

1   2019-04-10 10:49:00

2   2019-04-10 10:49:00

3   2019-04-10 10:49:00

4   2019-04-10 10:49:00

5   2019-04-10 10:48:00

6   2019-04-10 10:48:00

7   2019-04-10 10:48:00

8   2019-04-10 10:48:00

9   2019-04-10 10:48:00

Name: tweet.created_at, dtype: datetime64[ns]

input:

t.groupby(pd.core.resample.TimeGrouper('H').count().plot(kind='bar'))

output:

Error: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74
Vahid the Great
  • 393
  • 5
  • 18

1 Answers1

1

I use this trick to get around:

t.reset_index().set_index(t.name).resample('H').count().plot()
Vahid the Great
  • 393
  • 5
  • 18
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74