I am trying to spot sentences having identical repeated characters in the same word, for instance:
Sentence
are they saddddd?
I don't want to go
heyyyyy
12333
00unit
00wolf
01man
20595
2091996
03dumbdumb
In order to assign a value 1 or 0 if they contains repeated characters or not (expected output below):
Sentence Lab
are they saddddd? 1
I don't want to go 0
heyyyyy 1
12333 1
00unit 0
00wolf 0
01man 0
20595 0
2091996 0
03dumbdumb 0
I have tried as follows:
df.loc[(df['Sentence'].str.findall(r'([a-zA-Z])\1{3}').astype(bool)), 'Lab']=1
But it does not assign correctly the value 1 whether at least 3 identical characters are consecutive.
Can you please have a look at my code and tell me why it is not working?
Some values, like 00unit, 00wolf, 01man, 20595, 2091996, 03dumbdumb, are wrongly selected from the code above, as including three identical consecutive characters, while they do not have them.