You could either use .str again to get access to the string methods, or (better, IMHO) use case=False to guarantee case insensitivity:>>> df = pd.DataFrame({"body": ["ball", "red BALL", "round sphere"]})>>> df[df["body"].str.contains("ball")] body0 ball>>> df[df["body"].str.lower().str.contains("ball")] body0 ball1 red BALL>>> df[df["body"].str.contains("ball", case=False)] body0 ball1 red BALL>>> df[df["body"].str.contains("ball", case=True)] body0 ball(请注意,如果要进行分配,使用df.loc是更好的习惯,以避免可怕的SettingWithCopyWarning,但如果我们只是在此处选择,那就没关系了.)(Note that if you're going to be doing assignments, it's a better habit to use df.loc, to avoid the dreaded SettingWithCopyWarning, but if we're just selecting here it doesn't matter.)(注2:我真的不需要在此处指定回合".)(Note #2: guess I really didn't need to specify 'round' there..) 这篇关于通过包含str过滤 pandas 数据框行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-10 13:26