0

I have a dataframe, which is resampled to higher sampling rate like from 8hz to 16 hz.using

new_df = new_df.resample('62.5L').ffill()

the image before upsampling is here

instead of using ffill(), I tried to interpolate values using

interpolated = new_df.interpolate(method='linear', axis=0)

but the new data frame is having "nan" filled rather than interpolated values THE IMAGE AFTER UP SAPLING AND INTERPOLATING

Can anyone please help me in interpolating without filling nan in the columns !

Michael Szczesny
  • 4,911
  • 5
  • 15
  • 32
user5349
  • 123
  • 7
  • Thank you for reply. But following code worked. I had to convert each particular column to float if it is numeric data and then use interpolate command. for text columns I used fill. 1. for numeric data: df.iloc[:,1,2,3].astype(float).interpolate() 2. for text data: ips.iloc[:,bbbb].ffill() – user5349 Sep 18 '21 at 00:44

1 Answers1

0
interpolated = new_df.interpolate(method='time', axis=0)

This should work. I understand it's not linear (I'm not exactly sure why its giving NaN) but seeing as the difference between each timestamp is equal. This should give you what you're looking for.

DataPlug
  • 340
  • 3
  • 10
  • Thank you for reply. But following code worked. I had to convert each particular column to float if it is numeric data and then use interpolate command. for text columns I used fill. 1. for numeric data: df.iloc[:,1,2,3].astype(float).interpolate() 2. for text data: ips.iloc[:,bbbb].ffill() – user5349 Sep 18 '21 at 00:40