我有两个数据帧,我试图输出的数据是在一个,但不是另一个。你知道吗
我可以得到第一个数据帧中的数据,但不能使用第二个数据帧
only_new = old.merge(
new, 'outer', on=['Employee ID', 'Benefit Plan Type'],
suffixes=['','_'], indicator=True
).query('_merge == "left_only"').reindex_axis(old.columns, axis=1)
下面是我用来获取第二个数据帧中的数据
only_new =new.merge(
old, 'outer', on=['Employee ID', 'Benefit Plan Type'],
suffixes=['','_'], indicator=True
).query('_merge == "left only"').reindex_axis(new.columns, axis=1)
但是它不返回任何数据,但是使用Excel我可以看到应该有几行。你知道吗
看来这应该管用
only_new = old.merge(new, on='Employee ID', indicator=True, how='outer',
only_new[only_new['_merge'] == 'right_only'])
但我明白了
SyntaxError: non-keyword arg after keyword arg
考虑数据帧
old
和new
然后取对称同一解
似乎您需要将
'_merge == "left_only"'
更改为'_merge == "right_only"'
。你知道吗相关问题 更多 >
编程相关推荐