pandas to_datetime()
Posted 大大的橙子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pandas to_datetime()相关的知识,希望对你有一定的参考价值。
>>> import pandas as pd >>> i = pd.date_range(‘20000101‘,periods=100) >>> df = pd.DataFrame(dict(year = i.year, month = i.month, day = i.day)) >>> pd.to_datetime(df.year*10000 + df.month*100 + df.day, format=‘%Y%m%d‘) 0 2000-01-01 1 2000-01-02 ... 98 2000-04-08 99 2000-04-09 Length: 100, dtype: datetime64[ns] >>> df = df.astype(str) >>> pd.to_datetime(df.day + df.month + df.year, format="%d%m%Y") 0 2000-01-01 1 2000-01-02 ... 98 2000-04-08 99 2000-04-09 Length: 100, dtype: datetime64[ns]
以上是关于pandas to_datetime()的主要内容,如果未能解决你的问题,请参考以下文章