【发布时间】:2020-06-18 05:56:45
【问题描述】:
我有以下数据框
df = pd.DataFrame({
'Date': [1930, 1931, 1932, 1933,1934],
'Income': [2300000, 5698907, 5976753, 6086762, 6577780],
'Age': [22, 45, 35, 40, 28],
'Weight': [0.01, 0.003, 0.04, 0.08, 0.07]
})
每个变量都有不同的刻度值。我想在 1 个图表上绘制变量,但由于变量的比例差异,我只能看到收入线。我使用
绘制df.plot(figsize=(20,10), linewidth=5, fontsize = 20);
我决定根据我在网上找到的内容来显示比例,所以我做了以下事情:
import pandas as pd
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
df = scaler.fit_transform(df)
然后我尝试在特征缩放后绘制数据框,它给出了以下错误:
AttributeError: 'numpy.ndarray' object has no attribute 'plot'
我不知道从这里去哪里。目的是在一张图上绘制所有变量。
【问题讨论】:
-
您从该错误消息中了解/不了解什么?说到这里,请提供整个错误回溯/消息。还有,你分享的sn-ps代码好像有问题,是这样吗?
标签: python pandas dataframe feature-scaling