How to resolve "ValueError: cannot reindex on an axis with duplicate labels" error while processing time series data in pandas?
11:40 11 Aug 2022
                       cube   timestamp          temp   
timestamp               
2022-08-01 00:15:05.135  A1       2022-08-01 00:15:05.135    NaN

2022-08-01 00:15:37.255  A1       2022-08-01 00:15:37.255    23.17  

2022-08-01 00:23:05.139  A1       2022-08-01 00:23:05.139    NaN    

2022-08-01 00:23:15.137  A1       2022-08-01 00:23:15.137    NaN    

2022-08-11 11:33:20.738  P19      2022-08-11 00:15:05.135    NaN    

I am trying to interpolate NaN value in temperature based on the timestamp with respect to the cubes by using the below code

idata.set_index(idata['timestamp'],inplace = True)

idata['temp'] = idata.groupby('cube')['temp'].apply(lambda x:x.interpolate(method="time",limit_direction = "both"))

while executing this code, I am getting the error "ValueError: cannot reindex on an axis with duplicate labels". I cannot remove the duplicate labels(timestamp) as it may belong to different cubes. please suggest the alternative to handle this situation.

python pandas time-series valueerror