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