0

I am trying to remove special characters from a string, but when I export the Pandas dataframe as a CSV, I can still see the special characters.

Does anyone know why that is?

Current Code:

document = json.dumps(jfile,default=str) document2 = re.sub("[“â£$€™]", '', document) document2 = json.loads(document2) document2.to_csv("test.csv", index = False) 

Output (special character still found in CSV file):

enter image description here

2
  • Try document.str.replace("[“â£$€™]", '', regex=True) Commented Feb 12, 2021 at 14:21
  • 3
    You need to determine the encoding of the source file. Commented Feb 12, 2021 at 14:21

1 Answer 1

2

This seems the pandas Encoding problem. Try to read/load your file with the appropriate encoding.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.