[英]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.