简体   繁体   English

在Python中绑定数据

[英]Binning data in Python

I'm working very hard to understand how to bin data in Python. 我正在努力了解如何在Python中对数据进行装箱。 So far I have worked out how to get the edges using: 到目前为止,我已经解决了如何使用以下方法获得边缘:

edges = pylab.hist(data, bins=10)[1]

I'm not sure if this is the most ideal method, but it worked! 我不确定这是否是最理想的方法,但确实有效! Gives me a list of 11 numbers needed to make 10 bins. 给我列出制作10个垃圾箱所需的11个数字的列表。 Problem is that I'm at a loss as how to then classify data into bins. 问题是我不知道如何将数据分类到箱中。 I tried using: 我尝试使用:

digitized = np.digitize(data, edges)

But that just gave me an error, " ValueError: zero-size array to reduction operation minimum which has no identity ". 但这只是给了我一个错误,“ ValueError:零大小的数组,以最小化没有身份的缩小操作 ”。 I need to make bins somehow before using pandas value_counts (I have that part down already as well). 在使用pandas value_counts之前,我需要以某种方式制作垃圾箱(我已经把这部分放下来了)。

Any help would super appreciated! 任何帮助将不胜感激!

答案是:

digitized = np.digitize(data, edges)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM