1
我有一个熊猫数据帧这样的条件逻辑:大熊猫添加新列基于缺失值
aa bb cc dd ee
a a b b foo
a b a a foo
b nan a a bar
b b b b bar
我要像创建新列df['ff']
:
aa bb cc dd ee ff
a a b b foo c
a b a a foo c
a nan a a bar d
a b b b bar c
的逻辑是:我的答案应该是这样的:
df['ff'] = df.apply(lambda x: x['bb'].isnull(),axis=1) & (x['aa']=='a')
,但我得到了如下的错误:
("'str' object has no attribute 'isnull'", 'occurred at index 0')