Answers for "timedelta days to year pandas"

0

timedelta days to year pandas

In[1]: import pandas as pd
In[2]: df = pd.DataFrame([ pd.Timestamp('20150111'), 
                           pd.Timestamp('20150301') ], columns=['date'])
In[3]: df['today'] = pd.Timestamp('20150315')
In[4]: df
Out[4]: 
        date      today
0 2015-01-11 2015-03-15
1 2015-03-01 2015-03-15

In[5]: (df['today'] - df['date']).dt.days
Out[5]: 
0    63
1    14
dtype: int64
Posted by: Guest on September-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language