to_csv() Chinese garbled, Matplotlib plots Chinese garbled solution

Write garbled characters in to_csv() file;

Using Pandas to write data into a csv file appears garbled, the solution:

df.to_csv(file_name3,encoding="utf_8_sig")

Matplotlib draws charts to display Chinese, the solution:

#coding:utf-8
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
#有中文出现的情况,需要u'内容'

Guess you like

Origin blog.csdn.net/weixin_42512684/article/details/106929854