我想比较 2 个熊猫系列,并在两个系列中找到相同的条目,但区分大小写不同。
类似于下面的例子:
df['Comment']=np.where((df['Identifier_1']==df['Identifier_2']),'The same',df['Comment'])
但条件应该以某种方式改变,以便如果 Identifier_1='aBc' 和 Identifier_2='Abc' 然后返回 True。
谢谢 和 BR
df = pd.DataFrame({'Identifier_1':['aBc','aBC'],
'Identifier_2':['Abc','ABZ'],
'Comment':['com1','com2']})
df['Comment']=np.where(df['Identifier_1'].str.lower() == df['Identifier_2'].str.lower(),
'The same',
df['Comment'])
print (df)
Identifier_1 Identifier_2 Comment
0 aBc Abc The same
1 aBC ABZ com2
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句