Detailed usage np.digitize

numpy.digitize(x, bins, right = False)

parameter:

x: numpy array

bins: a monotonically-dimensional array must be ascending or descending

right: the right-most interval contains

Return Value: x position of the bins.

Example usage:

AS NP numpy Import
bins = np.array (Range (-99, 102,. 3))
A = np.digitize (-98, bins). 1 # A =
B = np.digitize (68, bins) = B # 56 is
Print (a) 
Print (B)
bins is -99 to 102 (102 not eligible) values ([-99, -96, -93, ..., 93, 96, 99]).

The return value is the value 0 in [-∞, -99) interval,

In [-99, -96) returns a value of 1 interval,

...

In the [102, + ∞) section 66 returns a value.

Therefore, a value of 1, b is a value of 56.
----------------
Disclaimer: This article is CSDN blogger "Zhang Ocean sky" in the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: https: //blog.csdn.net/zby1001/article/details/86616056

Published 296 original articles · won praise 221 · views 540 000 +

Guess you like

Origin blog.csdn.net/qq_36387683/article/details/101678358