【问题标题】:pandas special chars converted to weird chars when saving保存时熊猫特殊字符转换为奇怪字符
【发布时间】:2021-05-13 06:46:01
【问题描述】:

我有一系列文字:

s = ["t1" , "t1", "it wasn’t that simple"]

另存为 csv 时:

s.to_csv("s.csv")

然后在excel中打开,char'变成如下:

"it wasn’t that simple"

如何解决?

【问题讨论】:

    标签: pandas macos dataframe csv export-to-csv


    【解决方案1】:

    使用encoding='utf-16'

    例如:

    s = ["t1" , "t1", "it wasn’t that simple"]  
    s = pd.Series(s)
    s.to_csv(filename, encoding='utf-16', index=False)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      • 2019-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多