0

I want to convert the data which is recorded in 10Hz into 1Hz. I saw some solutions and i tried it, DO i need to use resample function?, do i need to convert timestamp into sec or minute something? My question is I have data in millions of rows when i convert that data 10Hz to 1Hz, data will get reduced or it will increase?

Would be great if you could help me, Thanks in advance.

start_timestamp end_timestamp interpreted_value Frequency
2020-11-24 07:14:24.903187 2020-11-24 07:14:25.003187 5.96875 10Hz
2020-11-24 07:14:25.003187 2020-11-24 07:14:25.103187 6.515625 10Hz
2020-11-24 07:14:25.103187 2020-11-24 07:14:25.203187 7.109375 10Hz
2020-11-24 07:14:25.203187 2020-11-24 07:14:25.303187 7.609375 10Hz
2020-11-24 07:14:25.303187 2020-11-24 07:14:25.403187 8.21875 10Hz

Below is the code i tried :

df1=df.resample('1S',on='start_timestamp').mean().dropna()
Or
df1=df.set_index('start_timestamp').resample('20L').mean().dropna()
SSS
  • 73
  • 11
  • Why didn't these work? are your timestamps strings or proper timestamp datatypes? – kubatucka Oct 21 '21 at 10:47
  • datatype is datetime ,it is not string. it worked, but i am not sure it is right or not, as my dataframe contains 3,30,000 rows and after this "df1=df.resample('1S',on='start_timestamp').mean().dropna()" command i have got only 30,000 rows. – SSS Oct 21 '21 at 15:01
  • the number of rows you'll get is exactly (start_timestamp[-1] - start_timestamp[0])/timedelta(freq) . If you're not sure just do it on the first 100 rows and check it manually. – kubatucka Oct 22 '21 at 18:13
  • Without sample data, current output and expected output we can't solve your issue. I don't know if you're missing 3000 rows because there are duplicates or nan values in your original data. – kubatucka Oct 22 '21 at 18:18

0 Answers0