how to search character plus using pandas.Series.str.contains

前端 未结 1 658
离开以前
离开以前 2021-01-24 02:58

How do I search the character \'+\' using \"pandas.Series.str.contains\" in a pandas dataframe column. I tried

df_noplus = df[df[\'column1\'].str.contains(\'+\'         


        
相关标签:
1条回答
  • Please use backslash berofe plus:

    df = pd.DataFrame({'a': ['+1','+2','-4']})
    
    df['a'].str.contains('\+')
    

    result:

    0     True
    1     True
    2    False
    Name: a, dtype: bool
    
    0 讨论(0)
提交回复
热议问题