Python: Convert timedelta to int in a dataframe

Python: Convert timedelta to int in a dataframe

Asked on December 24, 2018 in Pandas.
Add Comment


  • 2 Answer(s)

    Execute the below code where td is the timedeltas:

    import numpy as np
    (td / np.timedelta64(1, 'D')).astype(int)
    
    Answered on December 24, 2018.
    Add Comment

    The attributes such as .days, .seconds, and .microseconds are read only for timedelta objects.

    Answered on December 24, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.