0
furniture = furniture.groupby('Order Date')['Sales'].sum().reset_index()
print(furniture.head())

Output:

  Order Date     Sales
0 2014-01-06  2573.820
1 2014-01-07    76.728
2 2014-01-10    51.940
3 2014-01-11     9.940
4 2014-01-13   879.939

when i want to have month wise mean of sales.so added

y = furniture['Sales'].resample('MS').mean()

output:

TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'

I can understand my Order Date column is not in Timestamp Formate .I dont know how to convert it.

Any idea pl?

  • Does this answer your question? [Convert column to timestamp - Pandas Dataframe](https://stackoverflow.com/questions/50089903/convert-column-to-timestamp-pandas-dataframe) – Zaraki Kenpachi Sep 11 '20 at 09:56
  • 1
    Try `furniture.resample('MS', on='Order Date')['Sales'].mean()` – Chris Adams Sep 11 '20 at 09:59
  • @ChrisA its working thanks . what wrong on the above –  Sep 11 '20 at 10:03
  • 1
    Your calling the `resample` method without passing in which column to resample on, by default it will use the index. The index in this case is just an `int`. Resample can only be used on Datetime dtypes, so you need to specific which column using the `on=` param, or make sure you set the index to be your datetime field before resampling. – Chris Adams Sep 11 '20 at 10:04

0 Answers0