"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". "" "" "" "" "" "" "" "," "" "" "," "" "" "," "" "," "" ">> Pandas read csv file .py>> Author: Liu Yang>> blog: liuyang1.club>> Email: [email protected]>> Blog: Www.cnblogs.com/liu66blog "" "" "" "" "" "" "" "" "" "" "" "" "" "." "" "" "" "" "" "" "" "" "" "" "" "" "". " "" "" "" "#!/usr/bin/env python#-*-coding:utf-8-*-import matplotlibimport pandas as Pdimport NumPy as Npimport mat Plotlib.pyplot as plt# defines the font to be used to prevent Chinese garbled font=matplotlib.font_manager from appearing. Fontproperties (fname=r "C:\Windows\Fonts\Deng.ttf") # Add index index_col=0 Set first column index DF = pd.read_csv (U ' xxxx.csv ', encoding= ' Utf-8 ', index_col=0) # print (DF) Df_plot = Df.plot (kind= ' bar ', rot=0) # Set Header header Plt.title (' Student info ', Fontproperties=font) # The first parameter is the data sort, loc sets the legend position Plt.legend (loc=1) plt.xlabel (' name ', Fontproperties=font) Plt.ylabel (', Fontproperties=font ') Plt.xticks (Fontproperties=font) plt.yticks ([Y for y in range (0,, ten)],fontproperties=font) # for x, y, z in Zip (Df.get (' Height ')): # Plt.text ( -0.2,df.get ("height") [0], '%.0f '%df.get ("height") [0], ha= ' center ', va= ' bottom ') # Plt.text (0,df.get ("score") [0], '%.0f ' %df.get ("score") [0], ha= ' center ', va= ' bottom ') # Plt.text (0.15,df.get ("Age") [0], '%.0f '%df.get ("Age") [0], ha= ' Center ', va= ' bottom ') # df.to_csv (' data. csv ', encoding= ' Utf-8 ') # show Plt.show ()
[Python Study notes]pd.read_csv () function reads a CSV file drawing