如何将列的值替换为箱值的平均值?
给定以下 DataFrame 列:
0 -0.0985
1 -0.0880
2 -0.1068
3 -0.2338
4 -0.2807
5 -0.1570
6 -0.2043
7 -0.0776
8 -0.1572
9 -0.0501
10 -0.0926
11 -0.2075
Name: 2, dtype: float64)
以及 pandas.qcut
分类和 bin:
(0 bin_2
1 bin_3
2 bin_2
3 bin_0
4 bin_0
5 bin_1
6 bin_1
7 bin_3
8 bin_1
9 bin_3
10 bin_2
11 bin_0
Name: 2, dtype: category
Categories (4, object): ['bin_0' < 'bin_1' < 'bin_2' < 'bin_3']
如何创建具有相同大小的列,并将每个值替换为 bin 中值的平均值?
Given the below DataFrame column:
0 -0.0985
1 -0.0880
2 -0.1068
3 -0.2338
4 -0.2807
5 -0.1570
6 -0.2043
7 -0.0776
8 -0.1572
9 -0.0501
10 -0.0926
11 -0.2075
Name: 2, dtype: float64)
and the pandas.qcut
categorical and bins:
(0 bin_2
1 bin_3
2 bin_2
3 bin_0
4 bin_0
5 bin_1
6 bin_1
7 bin_3
8 bin_1
9 bin_3
10 bin_2
11 bin_0
Name: 2, dtype: category
Categories (4, object): ['bin_0' < 'bin_1' < 'bin_2' < 'bin_3']
How to create a column with the same size, and replace each value by the mean of the values in the bin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论