我正在尝试创建一个新的Pandas dataframe列,其中包含datetime列中的ordinal day:
import pandas as pd
from datetime import datetime
print df.ix[0:5]
date
file
gom3_197801.nc 2011-02-16 00:00:00
gom3_197802.nc 2011-02-16 00:00:00
gom3_197803.nc 2011-02-15 00:00:00
gom3_197804.nc 2011-02-17 00:00:00
gom3_197805.nc 2011-11-14 00:00:00
df['date'][0].toordinal()
Out[6]:
734184
df['date'].toordinal()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-dbfd5e8b60f0> in <module>()
----> 1 df['date'].toordinal()
AttributeError: 'Series' object has no attribute 'toordinal'
我想这是一个基本的问题,但在过去的30分钟里,我一直在努力阅读文档。
如何为数据帧创建顺序时间列?
您还可以使用
map
:使用应用:
相关问题 更多 >
编程相关推荐