首页 > 代码库 > pandas to_datetime()

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-011    2000-01-02...98   2000-04-0899   2000-04-09Length: 100, dtype: datetime64[ns]>>> df = df.astype(str)>>> pd.to_datetime(df.day + df.month + df.year, format="%d%m%Y")0    2000-01-011    2000-01-02...98   2000-04-0899   2000-04-09Length: 100, dtype: datetime64[ns]

 

pandas to_datetime()