选定列的标准化或归一化

发布于 2025-02-04 22:38:41 字数 195 浏览 2 评论 0原文

**from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train[:,5:7] = sc.fit_transform(X_train[:,5:7])**

在这里,我想选择第5、6和9列。

有没有办法在此处选择第9列?

**from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train[:,5:7] = sc.fit_transform(X_train[:,5:7])**

Here I want to select 5th, 6th and 9th columns.

Is there a way to select the 9th column here??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南城追梦 2025-02-11 22:38:41

为了选择第五,第6和9列,您可以使用.iloc。注意列索引从0开始。因此,5,6的索引和9列的索引为4,5和8。

    from sklearn.preprocessing import StandardScaler
    sc = StandardScaler()
    X_train.iloc[:, [4,5,8]] = sc.fit_transform(X_train.iloc[:, [4,5,8]])

In order to select 5th,6th and 9th columns, you can use .iloc. Note the column index starts from 0. So, the indices of 5,6, and 9th columns are 4,5 and 8.

    from sklearn.preprocessing import StandardScaler
    sc = StandardScaler()
    X_train.iloc[:, [4,5,8]] = sc.fit_transform(X_train.iloc[:, [4,5,8]])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文