相关疑难解决方法(0)

python pandas标准化回归列

我有以下df:

Date       Event_Counts   Category_A  Category_B
20170401      982457          0           1
20170402      982754          1           0
20170402      875786          0           1
Run Code Online (Sandbox Code Playgroud)

我正在为回归分析准备数据,并希望标准化Event_Counts列,以便它与类别类似.

我使用以下代码:

from sklearn import preprocessing
df['scaled_event_counts'] = preprocessing.scale(df['Event_Counts'])
Run Code Online (Sandbox Code Playgroud)

虽然我收到了这个警告:

DataConversionWarning: Data with input dtype int64 was converted to float64 by the scale function.
  warnings.warn(msg, _DataConversionWarning)
Run Code Online (Sandbox Code Playgroud)

它似乎有效; 有一个新专栏.但是,它有负数,如-1.3

我认为比例函数的作用是从数字中减去均值,并将其除以每一行的标准差; 然后将结果的min添加到每一行.

这种方式对熊猫不起作用吗?或者我应该使用normalize()函数还是StandardScaler()函数?我希望标准化列的比例为0到1.

谢谢

python normalize standardized scale pandas

1
推荐指数
1
解决办法
3363
查看次数

标签 统计

normalize ×1

pandas ×1

python ×1

scale ×1

standardized ×1