简体   繁体   English

找到具有 0 个特征 (shape=(10792, 0)) 的数组,而至少需要 1 个

[英]Found array with 0 feature(s) (shape=(10792, 0)) while a minimum of 1 is required

Hey I am using Jupitor Notebook and doing machine learning.嘿,我正在使用 Jupitor Notebook 并进行机器学习。 I wrote this code but getting this error and I dont know what is the error.我写了这段代码但得到了这个错误,我不知道错误是什么。 This is my code for reference:这是我的参考代码:

f`rom sklearn.experimental import enable_iterative_imputer
from sklearn.impute import IterativeImputer

imp = IterativeImputer(random_state=42)

date = pd.Timestamp('2200-01-01')

for col in combi:
    if combi[col].dtype=="object":
        combi[col].fillna("not listed", inplace=True)
    if combi[col].dtype=="int":
        #X[col].fillna(X[col].mode()[0], inplace=True)
        combi[col].fillna(combi[col].mean(), inplace=True)
        #combi[col] = combi[col].astype.int()
    if combi[col].dtype=='float':
       #X[col].fillna(X[col].mean(), inplace=True)
       combi[col] = imp.fit_transform(combi[col].values.reshape(-1,1))
    if combi[col].dtype=="datetime64[ns]":
        combi[col].fillna(date, inplace=True)
combi`

Solution of the problem问题的解决

This is not how for loops work in Python.这不是for循环在 Python 中的工作方式。

for col in combi:
    if combi[col].dtype=="object":
        # ...

col isn't an index into the collection you're iterating over ( combi ), it is the dereferenced element itself. col不是您正在迭代的集合的索引 ( combi ),它取消引用的元素本身。 Change all instances of combi[col] inside your for loop to col to correct.for循环内的所有combi[col]实例更改为col以更正。 Example:例子:

for col in combi:
    if col.dtype=="object":

You didn't post all of your code so it's unclear if this will resolved the problem you're seeing, but it is certainly a step in the right direction.您没有发布所有代码,因此不清楚这是否会解决您所看到的问题,但这肯定是朝着正确方向迈出的一步。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError:找到具有0个特征的数组(shape =(546,0)),而最少需要1个 - ValueError: Found array with 0 feature(s) (shape=(546, 0)) while a minimum of 1 is required 引发 ValueError ValueError: Found array with 0 feature(s) (shape=(124, 0)) 而最少需要 1 - raise ValueError ValueError: Found array with 0 feature(s) (shape=(124, 0)) while a minimum of 1 is required ValueError: 找到具有 0 个特征的数组 (shape=(2698, 0)),而 MinMaxScaler 要求最小值为 1 - ValueError: Found array with 0 feature(s) (shape=(2698, 0)) while a minimum of 1 is required by MinMaxScaler "找到具有 0 个样本的数组 (shape=(0, 5880)),而 MinMaxScaler 要求最小值为 1" - Found array with 0 sample(s) (shape=(0, 5880)) while a minimum of 1 is required by MinMaxScaler 找到具有 0 个样本 (shape=(0, 1)) 的数组,而至少需要 1 个 - Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required 找到具有 0 个样本的数组(形状 =(0, 40)),而最少需要 1 个 - Found array with 0 sample(s) (shape=(0, 40)) while a minimum of 1 is required ValueError:找到具有 0 个样本 (s) (shape= (0, 1) 的数组,而 MinMaxScaler 要求最小值为 1 - ValueError: Found array with 0 sample (s) (shape= (0, 1) while a minimum of 1 is required by MinMaxScaler Python 3 - ValueError:找到包含0个样本(shape =(0,11))的数组,而MinMaxScaler需要至少1个 - Python 3 - ValueError: Found array with 0 sample(s) (shape=(0, 11)) while a minimum of 1 is required by MinMaxScaler 如何解决以下错误:ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required - How to fix the following error: ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required 为什么在运行我的代码时出现错误:'ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required'? - Why am I getting the error: 'ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required' when running my code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM