根据比较Python中的2个数据框创建结果

时间:2018-11-12 19:44:40

标签: python pandas

我有2个数据帧,DF1和DF2。

DF1 = ['IDS'] ['DateTime'] DF2 = ['IDS'] ['最后期限']

IDS是STR,其他是DateTime。

我想在DF1中添加一个名为['Late']

的列

我的代码是

DF1['Late'] = DF1.where(DF1['IDS']==DF2['IDS'] and DF1['DateTime'] > DF2['Deadline'], "Late","Not Late")

我得到以下信息: ValueError:只能比较标记相同的Series对象

所以我在DF1中创建了一个新列[Deadline']

DF1['Late'] = DF1.where(DF1['IDS']==DF2['IDS'] and DF1['Deadline'] > DF2['Deadline'], "Late","Not Late")

但是我遇到了同样的错误?

谢谢

0 个答案:

没有答案