[英]Python histogram bins
I have this histogram: 我有这个直方图:
hist
(array([49, 33, 21, 11, 10, 9, 0, 0, 0, 2]), array([ 0. , 0.26274885, 0.52549769, 0.78824654, 1.05099538,
1.31374423, 1.57649308, 1.83924192, 2.10199077, 2.36473962,
2.62748846]))
which has 10 bins and the number of counts in each bin. 它有10个箱子和每箱的计数。 I would like to extract the first array, ie the number counts in each bin (array([49, 33, 21, 11, 10, 9, 0, 0, 0, 2]) to use for another calculation. 我想提取第一个数组,即每个bin (数组([49,33,21,11,10,9,0,0,0,2])中的数量计数,以用于另一个计算。
Is this possible? 这可能吗?
use hist[0]
使用hist[0]
Read more in the official tutorial 阅读官方教程中的更多内容
http://docs.python.org/2.7/tutorial/introduction.html#lists http://docs.python.org/2.7/tutorial/introduction.html#lists
Like string indices, list indices start at 0, and lists can be sliced, concatenated and so on: 与字符串索引一样,列表索引从0开始,列表可以切片,连接等等:
>>> a = ['spam', 'eggs', 100, 1234]
>>>
>>> a[0]
'spam'
>>> a[3]
1234
>>> a[-2]
100
>>> a[1:-1]
['eggs', 100]
>>> a[:2] + ['bacon', 2*2]
['spam', 'eggs', 'bacon', 4]
>>> 3*a[:3] + ['Boo!']
['spam', 'eggs', 100, 'spam', 'eggs', 100, 'spam', 'eggs', 100, 'Boo!']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.