检查一列中的值是否在另一列的列表中 [英] Check if a value in one column is in a list in another column

查看:44
本文介绍了检查一列中的值是否在另一列的列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的熊猫数据框:

I have a pandas dataframe like this:

,我需要知道city是否出现在citylist的列表中(忽略大小写).

and I need to know if city appears in the list in citylist (ignoring case).

我试图像这样使用apply,但是找不到正确的语法:

I've tried to use apply like this, but can't figure out the correct syntax:

df.apply(lambda x: x['city'].lower() in x['citylist'])

推荐答案

传递参数 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆