1

I have 50 residual values that are in the format 00:00:00.0000 under df['Residuals'] but hold actual values in a Pandas dataframe columns such as:

00:00:04.7328

00:00:01.4252

and so on. I want to calculate the rms value of these times in seconds but cannot convert them from this format to just a decimal format. The dtype of the listed values above says m8[ns] which I am unfamiliar with. My question is how can I convert it from this m8[ns] format to an integer and then run the calculations?

nf95
  • 23
  • 4
  • Seems like you have some versioning issues between `pandas` and `numpy`: https://stackoverflow.com/questions/29206612/difference-between-data-type-datetime64ns-and-m8ns – ALollz Sep 09 '19 at 20:05
  • @ALollz any recommendations then? I updated the numpy and pandas as suggested but nothing has changed. – nf95 Sep 09 '19 at 20:35
  • Is there a piece of reproducible code anywhere so we can recreate the problem? – Code Different Sep 10 '19 at 00:09

1 Answers1

0

The first thing to be paid attention to is the dtype, whether it's <m8[ns] (which is TimedeltaProperties) or <M8[ns] (which is DatetimeProperties)

In the case of <m8[ns]:

df['Residuals'].dt.seconds + df['Residuals'].dt.microseconds*1e-6 

should get you the answer.

In the case of <M8[ns]:

df['Residuals'].dt.second + df['Residuals'].dt.microsecond*1e-6 # without 's'

should get you the answer.

Hongpei
  • 677
  • 3
  • 13