Python uses plot paint, the figure does not show __python

Source: Internet
Author: User
the following data drawing results are not shown and the modification process is as follows
DF3 = {' Chinese ': 109, ' American ': A, ' German ':, ' Korea ': A ' Japan ': 5, ' England ': 118}
DF4 = PD. Dataframe (DF3)
df4.plot (kind= ' Barh ', rot=0)

Run Result: valueerror:if using all scalar values, your must pass a index
Reason: Missing index
After modification:

#方式1:
df4 = PD. Dataframe.from_dict (df3,orient= ' index '). T
df4.plot (kind= ' Barh ', rot=0)
print df4
#结果:
   Korea  England Chinese American  Japan
0      118      109      5
#方式2:
df5 = PD. Dataframe ({"Key": Df3.keys (), "value": Df3.values ()})
print Df5
#结果为:
        key  value
0     Korea
1   England    118
2   Chinese    109
3    German
4  American
5     Japan      5
# drawing statements:
Df4.plot ()
df5.plot (kind= ' Barh ', rot=0)
#运行以上语句图片不显示
#增加以下句子后出现图片
Import Matplotlib.pyplot as Plt
plt.show ()
Df4 's graph results

Df5 's graph results

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.