summaryrefslogtreecommitdiff
path: root/numpy/lib/nanfunctions.py
diff options
context:
space:
mode:
authorjaimefrio <jaime.frio@gmail.com>2014-01-09 10:23:07 -0800
committerjaimefrio <jaime.frio@gmail.com>2014-04-05 21:06:56 -0700
commiteae3d1a73f2f901da5956e3bcdaf2c44bfdd1ed3 (patch)
treeeacd0e21014656e4cf36fe617830697474d9166f /numpy/lib/nanfunctions.py
parent52d5d109f9dedf4f006b930abef9ff9c54ec1542 (diff)
downloadnumpy-eae3d1a73f2f901da5956e3bcdaf2c44bfdd1ed3.tar.gz
ENH: add a 'return_counts=' keyword argument to `np.unique`
This PR adds a new keyword argument to `np.unique` that returns the number of times each unique item comes up in the array. This allows replacing a typical numpy construct: unq, _ = np.unique(a, return_inverse=True) unq_counts = np.bincount(_) with a single line of code: unq, unq_counts = np.unique(a, return_counts=True) As a plus, it runs faster, because it does not need the extra operations required to produce `unique_inverse`.
Diffstat (limited to 'numpy/lib/nanfunctions.py')
0 files changed, 0 insertions, 0 deletions