简体   繁体   English

替换在 Pandas 中不起作用的特殊字符

[英]Replacing special characters not working in Pandas

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.我试图从字符串中删除特殊字符,但是当我将 Pandas dataframe 导出为 CSV 时,我仍然可以看到特殊字符。

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): Output(在 CSV 文件中仍然可以找到特殊字符):

在此处输入图像描述

This seems the pandas Encoding problem.这似乎是 pandas 编码问题。 Try to read/load your file with the appropriate encoding.尝试使用适当的编码读取/加载文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM