'how can i fix error: "Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'"?

I have a dataset containing various columns of created_at, text, author.id, i am trying to do a time analysis:

  df['date'] = pd.to_datetime(df['author.created_at'])
    df = df.set_index('date') 
    timestamp = (df_time!=0).resample('AS').sum()

I am getting error as:

enter image description hereTypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index'

Can anyone help me with this?Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source