Questions tagged [numpy-indexed]

It is a package that contains functionality for indexed operations on numpy ndarrays, providing efficient vectorized functionality such as grouping and set operations. The tag must be used for questions related to THIS package in particular and NOT for indexing operation in numpy.

For more details on this package regarding its features, installation and more visit THIS PAGE

5 questions
3
votes
2 answers

Efficient use of numpy_indexed output

>>> import numpy_indexed as npi >>> import numpy as np >>> a = np.array([[0,0,1,1,2,2], [4,4,8,8,10,10]]).T >>> a array([[ 0, 4], [ 0, 4], [ 1, 8], [ 1, 8], [ 2, 10], [ 2, 10]]) >>> npi.group_by(a[:,…
Tony
  • 781
  • 6
  • 22
2
votes
1 answer

weighted numpy bincount for 2D IDs array and 1D weights

I am using numpy_indexed for applying a vectorized numpy bincount, as follows: import numpy as np import numpy_indexed as npi rowidx, colidx = np.indices(index_tri.shape) (cols, rows), B = npi.count((index_tri.flatten(), rowidx.flatten())) where…
ttsesm
  • 917
  • 5
  • 14
  • 28
0
votes
1 answer

numpy - anyway to improve this further(PandasTook(1h26m), NumpyTakes(38m))

Initially had everything written pandas and for this exploratory exercise i had did a lot of groupby's and while running with the whole data it was ran for 1h 26m. Over the last weekend, i had changed everything from pandas to using numpy, currently…
bobby.dreamer
  • 366
  • 4
  • 19
0
votes
1 answer

Masking a Numpy array and applying a calculation per mask without using a for loop

Let's say we have the following data array: data_array = np.array([[1, 1, 1], [1, 1, 2], [2, 2, 2], [3, 3, 3], [4, 4, 4]], np.int16) data_array array([[1, 1, 1], [1, 1, 2], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) And we want…
cf2
  • 581
  • 1
  • 7
  • 17
0
votes
1 answer

Tensorflow Error when indexing a 4D array: ValueError: Shapes must be equal rank, but are 1 and 0

I'm modifying a simple CNN in Tensorflow and when I'm indexing a 4d array I get this error. My reproducable example is: from __future__ import print_function import pdb import numpy as np import tensorflow as tf from…
Ash
  • 3,428
  • 1
  • 34
  • 44