码迷,mamicode.com
首页 > 其他好文 > 详细

pandas to_datetime()

时间:2017-06-30 11:07:09      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:nbsp   time()   str   mon   panda   data   frame   style   class   

>>> 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()

标签:nbsp   time()   str   mon   panda   data   frame   style   class   

原文地址:http://www.cnblogs.com/dadadechengzi/p/7097771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!