Replacing copyright symbol python

Viewed 31

I'm trying to remove copyright symbols in my dataframe. I can recognise the symbol using:

symbol = u'\N{COPYRIGHT SIGN}'.encode('utf-8')
symbol = symbol.decode('utf-8')

But when I then try to replace it, this doesn't work:

print(df_one.replace(symbol, ''))

Do I need to read the data in differently somehow? I'm currently using:

df_one = pd.concat(map(pd.read_csv, glob.glob('data/*.csv')))
2 Answers

You should use the "loc" method with the replace function:

df.loc[:, "column_name"].replace({character},regex=True)

averroes response almost worked. This is the solution I now have that does work:

df.loc[:, "column_name"].replace({symbol: ' '},regex=True)
Related