savi
savi

Reputation: 67

Replacing copyright symbol python

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')))

Upvotes: 1

Views: 278

Answers (2)

savi
savi

Reputation: 67

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

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

Upvotes: 1

Ibn Masood
Ibn Masood

Reputation: 1113

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

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

Upvotes: 1

Related Questions