AttributeError:“系列"对象没有属性“重塑" [英] AttributeError: 'Series' object has no attribute 'reshape'

查看:111
本文介绍了AttributeError:“系列"对象没有属性“重塑"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用sci-kit学习线性回归算法. 缩放Y目标功能时:

I'm using sci-kit learn linear regression algorithm. While scaling Y target feature with:

Ys = scaler.fit_transform(Y)

我知道了

ValueError:预期的2D数组,取而代之的是1D数组:

ValueError: Expected 2D array, got 1D array instead:

之后,我使用:

Ys = scaler.fit_transform(Y.reshape(-1,1))

但是又出现了错误:

AttributeError:系列"对象没有属性重塑"

AttributeError: 'Series' object has no attribute 'reshape'

所以我检查了pandas.Series文档页面,上面写着:

So I checked pandas.Series documentation page and it says:

reshape(* args,** kwargs)从版本0.19.0开始不推荐使用.

推荐答案

解决方案已链接到需要插入Y.reshape(-1,1),您需要使用:

Insted of Y.reshape(-1,1) you need to use:

Y.values.reshape(-1,1)

这篇关于AttributeError:“系列"对象没有属性“重塑"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆