python num 0_熊猫数据帧:值错误:num必须是1<=num<=0,而不是1

博客分析了一个值错误,该错误出现在matplotlib库中,提示'num必须是1<=num<=0'。问题根源在于传入histogram的列数为0。解决方案涉及检查并正确格式化输入数据,确保数据框不包含空数组。提供了一个示例数据集,当使用正确格式的数据时,程序能正常运行。
摘要由CSDN通过智能技术生成

所以我很确定你的问题与数组train_x的格式有关。我用10000行6列的数组尝试了你的程序,它工作得很好,所以问题不是大小。出于某种原因,len(x_train)或len(x_train[0])中的一个是0。我之所以这么认为是因为:

您得到的值错误来自matplotlib.axes.\u子块模块,该模块处理在一个大图中绘制许多小子块(因此每个小直方图)。模块代码如下:"""

*rows*, *cols*, *num* are arguments where

the array of subplots in the figure has dimensions *rows*,

*cols*, and where *num* is the number of the subplot

being created. *num* starts at 1 in the upper left

corner and increases to the right.

"""

rows, cols, num = args

rows = int(rows)

cols = int(cols)

if isinstance(num, tuple) and len(num) == 2:

num = [int(n) for n in num]

self._subplotspec = GridSpec(rows, cols)[num[0] - 1:num[1]]

else:

if num < 1 or num > rows*cols:

raise ValueError(

"num must be 1 <= num <= {maxn}, not {num}".fo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值