0

The dataframe is

Date                       Amount
2019-07-01T00:00:00+05:30  2055359.98
2019-07-01T00:00:00+05:30  2055359.98
2019-07-01T00:00:00+05:30  145198200.0
2019-07-01T00:00:00+05:30  145198200.0
2019-07-02T00:00:00+05:30  1924232.72
2019-07-02T00:00:00+05:30  137860984.9 
2019-07-02T00:00:00+05:30  137466690.88
2019-07-02T00:00:00+05:30  138102066.04

Unable to resample the the below dataframe with dates on sum. I've tried below code to resample into two dates

d = df.resample('D', on='Date').sum()

The error is

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

I tried converting date column to index and converted to datetime before converting it into index. But the error is :

DatetimeIndex(['2019-07-01', '2019-07-01', '2019-07-01', '2019-07-01', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-02', '2019-07-09', '2019-07-09', '2019-07-12', '2019-07-12', '2019-08-19', '2019-08-19', '2019-09-10', '2019-09-10', '2019-09-12', '2019-09-12', '2019-09-12', '2019-09-12', '2019-09-13', '2019-09-13', '2019-09-13', '2019-11-21', '2019-11-22', '2019-11-25', '2019-11-25', '2019-11-25'], dtype='datetime64[ns]', name='TRANSACTIONDATE', freq=None)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Nithin Reddy
  • 580
  • 2
  • 8
  • 18

0 Answers0