【发布时间】:2017-01-27 15:16:25
【问题描述】:
我正在从 pandas 数据框中绘制一个列的直方图:
%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
df.hist(column='column_A', bins = 100)
但出现以下错误:
62 raise ValueError(
63 "num must be 1 <= num <= {maxn}, not {num}".format(
---> 64 maxn=rows*cols, num=num))
65 self._subplotspec = GridSpec(rows, cols)[int(num) - 1]
66 # num - 1 for converting from MATLAB to python indexing
ValueError: num must be 1 <= num <= 0, not 1
有谁知道这个错误是什么意思?谢谢!
【问题讨论】:
-
column_A的数据类型是什么 - 它是数字数据类型吗? -
@MaxU:你是对的。我忘了转换类型。感谢您的提醒。现在工作
-
你能更清楚地告诉我你是如何解决你的问题的吗?我有同样的问题:
yearly_average[:10].hist(column='year')
标签: pandas dataframe histogram