gpt4 book ai didi

python - Lambda 排除包含字符串列表的值

转载 作者:太空宇宙 更新时间:2023-11-04 11:12:18 24 4
gpt4 key购买 nike

<分区>

如果我的 pandas 数据框中有某些值,我想排除它们。

excluded_url_subpath = ['/editer', '/administration', '/voir-les-transactions', '/modifier', '/diffuser', '/creation-paiement']

所以我有一个可行的解决方案,可以像这样一一解决:

df = df[df['pagepath'].map(lambda x: False if '/editer' in x else True)]
df = df[df['pagepath'].map(lambda x: False if '/administration' in x else True)]
...

或者我可以使用我写的列表。但我尝试了一些东西,IDE 告诉我无法访问变量 x

df = df[df['pagepath'].map(lambda x: False for i in excluded_url_subpath if x in i)]

这里哪里出错了?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com