Skip to content Skip to sidebar Skip to footer

Pandas - Resampling And Interpolation With Time Float64

I want to resample and interpolate a panda serie. However my index is in float64 like this : Value Time 0.0 0.00 0.0 0.00 0.0 0.00 0.0 0.00 0.0

Solution 1:

I think you can convert floats to_timedelta and then is possible use resample with some aggregate function like sum or mean:

df.index = pd.to_timedelta(df.index, unit='ms')
df = df.resample('d')['Value'].sum()

df = df.resample('d')['Value'].mean()

Solution 2:

The error you recieved tell yous that pandas wants a time-based index. Resampling with pandas only works in a time-date format. You could either, convert the floats into a time and date format, but that doens't seem appropriate in your example. The other and (preferred) option would be to use something like scipy's signal.resample which takes in a numpy array:https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.resample.html

Post a Comment for "Pandas - Resampling And Interpolation With Time Float64"