data['normAmount']=StandardScaler().fit_transform(data['Amount'].reshape(-1,1))
报错:AttributeError: ‘Series’ object has no attribute ‘reshape’
原因:data是dataFrame数据结构,data[‘Amount’]取dataframe的一个column,输出格式为series,series不具有reshape属性
解决办法:用values方法将Series对象转化成numpy的ndarray,再用ndarray的reshape方法.
data['normAmount']=StandardScaler().fit_transform(data['Amount'].values.reshape(-1,1))
搞定
参考:https://blog.csdn.net/qq_36448051/article/details/81592379
知识点补充:
series.values
Return Series as ndarray or ndarray-like depending on the dtype.
即将series转化成numpy的ndarray
http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.values.html