All Questions
28 questions with no upvoted or accepted answers
1vote
1answer
44views
IndexError: an index can only have a single ellipsis ('...')
I have the following numpy 4D array: import numpy as np X = np.random.rand(5, 1, 10, 4) # so for example, first 2 elements: X[:2] array([[[[0.27383924, 0.48908027, 0.64997038, 0.20394247], [...
1vote
1answer
82views
Sort numpy array with many dimensions, leaving contained 2d blocks intact
i hope someone can help me. I have a numpy array with 5 dimensions: my_array = {ndarray: (256,256,256,4,3,3)} I want to sort it by the last dimension(4), leaving intact the 3x3 blocks. Put ...
1vote
1answer
163views
Reshape ndarray broadcasting values to new axis
Assume that I have an array with shape (6, 4, 512, 512) and I have another array of shape (6, 512, 512). How could I reshape the second array so it has the same shape as the first one? Also, would ...
1vote
4answers
91views
Python reshaping an array
This is a pretty specific question. I have this array: x = np.array([[[-3, 0], [0, 0]], [[0, 0], [0, -3]], [[2, 0], [0, 0]], [[-3, 0], [0, 0]]]) [[[-3 0] [ 0 0]] [[ 0 0] [ 0 -3]] [[2 0] [...
1vote
0answers
67views
Why do some elements in list of lists get converted into float datatype, but some do not?
This is the code where I am reading a csv file to convert into a list of lists so that I can then convert the list of lists into numpy array. These are the columns in the csv file: pickup_year: The ...
1vote
2answers
166views
Make with numpy an array that contains every cell its index multiplication, without loops
I want to make a function which get an int called "n" (4 for example), and make with it a numpy array which every cell contains its index multiplication. I want to make it without any loops. For ...
1vote
1answer
302views
Fastest iteration over 2 dimensions in python
Which is the fastest way to iterate over a 2 dimension array in python? Considering i always need x and y indexes. Example, i have this code that tries to 'match' 3 of the same number in a matrix, if ...
0votes
1answer
74views
Fix this numpy-function so it accepts multidimensional inputs
I am trying to compute the following function: geo-decay-function: in numpy, has to be vectorized. The catch in this case is that it should work for multidimensional inputs. E.g., x having dimensions ...
0votes
1answer
126views
Mean absolute value along all columns of a 3D Numpy array
I always get find myself in state of confusion when dealing with a multi-dimensional array. Imaging having the following array of arrays, where each array contains feature importance scores (3-...
0votes
0answers
31views
Selecting Array Values With A Separate Array of Indices
I am attempting to index a stacked 3-D Numpy array (named stack) by a group of 2-D indices contained inside of a separate Numpy array (named piece). The separate array contains several groups of 2-D ...
0votes
1answer
80views
move/translate values of 2d array by a specific amount (up)
I would like to understand various 2d array translation approaches. I have a method which returns a list of (x, y) coordinate indexes corresponding to values that should be deleted in the 2d array. ...
0votes
0answers
50views
How to extract common elements from nD numpy arrays? Tried but it's not efficient
I have a NumPy array that looks similar to the pythonic list of lists of lists (if I am correct to say lists twice) given as below: tempo= [ array([[ 3, 9],[12, 16],[19, 20]], dtype=int64), ...
0votes
2answers
187views
How to delete a specific element from a numpy nd array?
I am working on nd-arrays whose dimensions can vary. I want to delete specific elements from the array given its index. like x = [[1,2,3],[4,5,6]] index = (0,0) I am expecting to get the result as ...
0votes
0answers
65views
Optimising array assignment in Numpy
What I have is an image-building function that takes "rects" which are arrays of 8 elements, all in range 0-1. Then, they are converted from 0-1 to real coordinates using the target Width ...
0votes
1answer
24views
Aggregating labels of array for which corresponding input array contains all zero rows of input
I am having a multi-dimensional numpy array of input such as this: X = np.array([ [[[1.0, 1.0, 1.0], [1.0, 3.0, 1.0], [0.0, 0.0, 0.0], [0.0, 0.0,...