Replace double backslash in Pandas csv file

Python 3.9.5/Pandas 1.1.3

I have a very large csv file with values that look like:

Ac\Nme Products Inc.

and all the values are different company names with double backslashes in random places throughout.

I’m attempting to get rid of all the double backslashes. It’s not working in Pandas. But a simple test against the standalone value just using string.replace does work.


org = "Ac\Nme Products Inc."
result = org.replace("\","")

returns AcNme Products Inc. as the output, as I would expect.

However, using Pandas with the names in a csv file:

import pandas as pd
csv_input = pd.read_csv('/Users/me/file.csv')
csv_input.replace("\", "")
csv_input.to_csv('/Users/me/file_revised.csv', index=False)

When I open the new file_revised.csv file, the value still shows as Ac\Nme Products Inc.


Here is a snippet of file.csv as requested:

id,company_name,address,country  1000566,A1 Comm\Nodity Traders,LEVEL 28 THREE PACIFIC PLACE 1 QUEEN'S RD EAST HK,TH 1000579,"A2 A Mf\g. Co., Ltd.",53 YONG-AN 2ND ST. TAINAN TAIWAN,CA 1000585,"A2 Z Logisitcs Indi\Na Pvt., Ltd.",114A/1 1ST FLOOR SOUTH RAJA ST TUTICORIN - 628 001 TAMILNADU - INDIA,PE


Pandas doesn’t have a dataframe level string operation, but it can be updated per-column:

for col in csv_input.columns:
    if col == 'that_int_column':
    csv_input[col] = csv_input[col].str.replace(r"\N", "")