Home>

In the column of residence of a DataFrame
I want to determine if the symbol [|] is included.
I can't find a good way.

Currently

Applicable source code
'|' in df ['date of birth']
'' '
output is False
'' '

I tried the find function etc., but an error occurred and it did not work. . .

  • Answer # 1

    Kana

    import pandas as pd
    df = pd.DataFrame ({'date of birth': [
        'lllllllll', # All Small L
        '||||||||' ', # All vertical bar
        '111111111', # All Number
        '1111 | llll'
        ]})
    print (df ['Birthday']. str.find ('|')! =-1)
    "" "
    0 False
    1 True
    2 False
    3 True
    "" "
    print (df [df ['Birthday']. str.find ('|')! =-1])
    "" "
            Birthday
    1 |||||||||| 1
    3 1111 | llll
    "" "