import pandas as pd
df = pd.read_csv('911.csv')
df['desc'].str.replace('[^a-zA-Z0-9]','').head()
0 REINDEER CT & DEAD END; NEW HANOVER; Station ...
1 BRIAR PATH & WHITEMARSH LN; HATFIELD TOWNSHIP...
2 HAWS AVE; NORRISTOWN; 2015-12-10 @ 14:39:21-St...
3 AIRY ST & SWEDE ST; NORRISTOWN; Station 308A;...
4 CHERRYWOOD CT & DEAD END; LOWER POTTSGROVE; S...
Name: desc, dtype: object
I'm trying to remove all non-alphanumerical characters in the desc column. I tried the same code with other columns but it doesn't seem to be working.
[^a-zA-Z0-9]will also match for non-ASCII alphabetic characters for example this could turnDüsseldorfintoDsseldorf. If you want to preserve non-ASCII alphabetic character consider using\wrather thana-zA-Z.