Reputation: 213
I have this 146 days 12:37:08.787241
but I want just number of days in integer. For some reason when I df['days'].astype(int)
it's giving me an error
cannot astype a timedelta from [timedelta64[ns]] to [int32]
but astype
seems to be the solution for many other people
Upvotes: 5
Views: 8086
Reputation: 88305
For a single value, you can use Timedelta.days
td = pd.to_timedelta('146 days 12:37:08.787241')
td.days
146
However, for a pandas Series
of Timedeltas you'll need the dt
accessor
my_pd_series.dt.days
Upvotes: 8