how to extract days as integers from a timedelta64[ns] object in python

后端 未结 3 2015
南方客
南方客 2021-02-04 19:19

I have a pandas dataframe with a column like:

In [96]: data[\'difference\']
Out[96]: 
0                 NaT
1     1 days 21:34:30
2     0 days 16:57:36
3     0 d         


        
3条回答
  •  情深已故
    2021-02-04 19:46

    This should convert your timedelta64[ns] type to float64 representing days:

    data['difference'].astype('timedelta64[D]')
    

提交回复
热议问题