Reputation:
I tried to extract all punctuation in this list ['!',';','?','...','<<','>>'] as follows:
my_data['My_Column'].str.findall(r'[?!.,?;...<<>>]*')
For instance
df['Test']
I really like Python!!
I don't like Gordon Ramsey...
He said: << I do not agree with you >>
Expected output:
df['Test']
[!!]
[...]
[<<,>>]
I'd appreciate if you can tell me how to fix my code.
Upvotes: 1
Views: 54
Reputation: 323356
Check with
df.Test.str.findall(r'[?!.<>]+')
Out[133]:
0 [!!]
1 [...]
2 [<<, >>]
Name: Test, dtype: object
Upvotes: 1