- spacepy.toolbox.arraybin(array, bins)¶
Split a sequence into subsequences based on value.
Given a sequence of values and a sequence of values representing the division between bins, return the indices grouped by bin.
the input sequence to slice, must be sorted in ascending order
- dividing lines between bins. Number of bins is len(bins)+1,
value that exactly equal a dividing value are assigned to the higher bin
indices for each bin (list of lists)
>>> import spacepy.toolbox as tb >>> tb.arraybin(range(10), [4.2]) [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]