Search code examples
pythonpandasaccelerometer

accelerometer is sampled at high frequency , how to convert UTC time to float time?


 import pandas as pd
 df = pd.DataFrame(['Time':['16:47:55.510','16:47:55.511','16:47:55.410']})
 df

 output:
            Time
 0      16:47:55.510
 1      16:47:55.511
 2      16:47:55.410

how to convert this time values to float value using python?


Solution

  • If the time is in h:m:s.ms format you can do something like this:

    hours, minutes, seconds = df.Time[0].split(':')
    total_seconds = int(hours) * 3600 + int(minutes) * 60 + float(seconds)