【发布时间】:2021-09-11 04:20:45
【问题描述】:
我正在使用 StandardScaler 来缩放我的数据框,如下所示,我收到错误 ypeError: fit() missing 1 required positional argument: 'X'。我不确定问题出在哪里?感谢您的帮助。
import seaborn as sns
import pandas as pd
from random import randrange
import random
import numpy as np
from sklearn.preprocessing import StandardScaler # for feature scaling
random.seed(10)
df = pd.DataFrame()
for i in range(0,50):
df = df.append({'x': randrange(1,10),
'y': randrange(10,21),
'depth':randrange(400,601)}, ignore_index=True)
df.head()
depth x y
0 523.0 1.0 16.0
1 518.0 1.0 13.0
2 567.0 8.0 14.0
3 533.0 3.0 10.0
4 419.0 8.0 15.0
scaler = StandardScaler
scaler.fit(df)
df_scaled= scaler.transform(df)
错误是:
TypeError Traceback (most recent call last)
<ipython-input-40-98ea46087b3f> in <module>
4 scaler = StandardScaler
5
----> 6 scaler.fit(df)
7 df_scaled= scaler.transform(df)
TypeError: fit() missing 1 required positional argument: 'X'
【问题讨论】:
-
与
scaler.fit(X=df)相同的错误?
标签: python pandas scikit-learn