我有以下数据框:-
我想过滤claim_status
中有11个的地方
对于aa1的claim_ststaus_reason
。你知道吗
我正在尝试下面的代码,但它只是给我所有的行
my_list = 'aa1'
df[df['claim_status_reason'].str.contains( "|".join(my_list), regex=True)].reset_index(drop=True)
预期输出:-你知道吗
1.) where there is 11 in claim_ststus
2.) where there is aa1 in the claim_status_reason
不要对序列中的列表使用字符串操作。你可以用列表理解代替。您的数据结构选择是反熊猫的,因为您首先应该尽量避免将列表串联起来。这些操作不可矢量化。你知道吗
您可以使用
apply
获得所需的过滤器,如:相关问题 更多 >
编程相关推荐