Python: Convert timedelta to int in a dataframe
Question: I would like to create a column in a pandas data frame that is an integer
representation of the number of days in a timedelta column. Is it possible to
use 'datetime.days' or do I need to do something more manual?

**timedelta column**

> 7 days, 23:29:00

**day integer column**

> 7


Answer: You could do this, where `td` is your series of timedeltas. The division
converts the nanosecond deltas into day deltas, and the conversion to int
drops to whole days.

    
    
    import numpy as np
    
    (td / np.timedelta64(1, 'D')).astype(int)
    

