繁体   English   中英

检查 pandas 的另一列中是否存在搜索键的值?

[英]Check whether a value for search key exists in aanother column in pandas?

我的 dataframe 中有一个列,其中包含电话号码和其他具有 call_status 的列。 我想检查一次电话号码是否连接,然后一个新列应该返回 True 否则为 false。

我的数据如下:在此处输入图像描述

我的 output 需要在这里输入图片描述

masked df上使用isin

df['Customer Number'].isin(df[df['Call Status']=='Contacted']['Customer Number'])

output:

0     True
1    False
2     True
3    False
4    False
Name: Customer Number, dtype: bool

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM