当我尝试使用pandas绘制CSV数据时,只显示图形轴

2024-10-02 00:29:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个带有邮政编码的CSV文件,每个邮政编码对应一个数字。我想用柱状图来绘制它,但是现在只显示轴,没有实际的信息

import pandas as pd 
import matplotlib.pyplot as plt

installedbase = 'zipcode.csv'

df = pd.read_csv(installedbase)

df.plot(x = 'zip_code_installed', y = 'installed_NP', kind = 'hist', rwidth = .5, bins = 1000 )
plt.xlabel('zip code')
plt.ylabel('NP sum')
plt.axis([9000,9650,0,6400])

plt.show()

我用熊猫和matplotlib来绘图。”“x”和“y”在我的CSV文件中都设置为不同的列


Tags: installed文件csvimportdfmatplotlibasnp

热门问题