【发布时间】:2018-11-02 13:21:18
【问题描述】:
我有以下数据框:-
我想过滤claim_status 中有 11 个的地方
对于 claim_ststaus_reason,对于 aa1。
我正在尝试下面的代码,但它只是给了我所有的行
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
【问题讨论】:
-
有没有文本格式的dataFrame,可以快速测试一下。
-
是的,我知道如何分享
-
请这样做,但值得尝试
df.apply(lambda col: col.str[0]) -
df.mask(lambda x: 11 in x['claim_status_reason'])?
标签: python python-2.7 pandas dataframe