Vinicius Corrêa
Vinicius Corrêa

Reputation: 19

Contain in pandas isn t works

I'm trying to search "..." inside dataframe in a spacific column but the code below is not working

res.loc[res.Description.str.contains(pat ='...', regex = True)]

Could someone help me?

Upvotes: 0

Views: 30

Answers (1)

jezrael
jezrael

Reputation: 862611

Use regex - escape . because special character and add {3} for test at least 3 consecutive dots:

res = pd.DataFrame(
    {
        "Description": ["A...","B","C.","D..","..E...","F....."],
    }
)

df = res.loc[res.Description.str.contains(pat=r'\.{3}', regex = True)]
print (df)
  Description
0        A...
4      ..E...
5      F.....

Upvotes: 2

Related Questions