我有一个数据框,前两列是'number'和'date','number'中的某些值应该是'date',例如:
number date
10 2013-10-29 00:00:00 nan
我想将2013-10-29 00:00:00从df.ix [10] ['number']移至df.ix [10] ['number'],这是我的代码:
for a in in df['number'].index:
if isinstance(df.ix[a]['number'], datetime.datetime):
df.ix[a]['date'] = df.ix[a]['number']
df.ix[a]['number'] = np.nan
但似乎它根本不会改变df.ix [a] ['date']或df.ix [a] ['number']的值。或者有更好的方法将值从当前单元格移动到正确的单元格吗?
btw type(df.ix [a] ['number'])= float type(df.ix [a] ['date'])= datetime.datetime
谢谢!