[Python Study Notes]pd.read_csv () function reads a CSV file drawing

Source: Internet
Author: User
Tags pandas read csv

"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "". "" "" "" "" "" "" "" "," "" "" "," "" "" "," "" "," "" ">> 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.