Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.resha

1 数据归一出现的resape问题:

data['标准化累计票房'] = scaler.fit_transform(data['累计票房'])


ValueError: Expected 2D array, got 1D array instead:
array=[ 4742.92  3398.    2491.9   2149.    2070.  ].
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.

2 修改后:

data['标准化累计票房'] = scaler.fit_transform(data['累计票房'].reshape(-1,1))

如果是python3这里可能会出现警告:FutureWarning。因为reshape方法在后续会取消,所以改用values.reshape(-1,1)

3 最终修改:

data['标准化累计票房'] = scaler.fit_transform(data['累计票房'].values.reshape(-1,1))

 

你可能感兴趣的:(python运行相关问题)