Remove “days 00:00:00”from dataframe [duplicate]

杀马特。学长 韩版系。学妹 提交于 2021-02-10 16:42:30

问题


So, I have a pandas dataframe with a lot of variables including start/end date of loans. I subtract these two in order to get their difference in days. The result I get is of the type i.e. 349 days 00:00:00. How can I keep only for example the number 349 from this column?


回答1:


Check this format,

df['date'] = pd.to_timedelta(df['date'], errors='coerce').days

also, check .normalize() function in pandas.



来源:https://stackoverflow.com/questions/58059278/remove-days-000000from-dataframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!