我使用 sklearn 使用此代码转换数据。
sc = MinMaxScaler()
test= df['outcome']
y = sc.fit_transform(test)
Run Code Online (Sandbox Code Playgroud)
它显示这样的错误。
ValueError: Expected 2D array, got 1D array instead:
array=[ 21000. 36000. 5000. ... 7000. 12000. 11000.].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
Run Code Online (Sandbox Code Playgroud)
如何解决?
我使用 while 循环在数据框中显示数据
while True:
last_id = get_last_id()
res = df.iloc[last_id + 1]
Run Code Online (Sandbox Code Playgroud)
当 last_id 数据结束并仍然使用 last_id + 1 时显示错误
IndexError: single positional indexer is out-of-bounds
Run Code Online (Sandbox Code Playgroud)
我可以检查数据帧索引中是否没有 last_id + 1 然后不显示任何内容吗?