Let us have a numpy array (float) with shape equal to (36, 2, 400, 400). Let us say the 400 by 400 represents an image. Then for each pixel I would like to find the two values (second dimension) which are when taking the norm over the second…
I have the following data
>>> import numpy as np
>>> original_classes=np.load("classes.npy")
>>> original_features=np.load("features.npy")
These NumPy arrays have the following shapes
>>> original_classes.shape
(12000,)
>>>…
I have a list that describes a profile, such as the next one:
dat=[(0, 5),(1, 1),(3,1)]
I need to create a discretized version of that profile give a step of time 'dt=0.2'. For instance, the firs column of 'dat' would be:
dt = 0.2
time =…
I am relatively new to Python and I have written a class that contains a numpy.ndarray (containing ordinary Python int objects) for storing some data.
I would like to implement __getitem__ and __setitem__ in a way that behaves intuitively for…
I am trying to conduct logical slicing on two lists and then concatenate them together while maintaining the original indicies.
Here is what I currently have:
x = np.array([0,12,2,246,13,42,245,235,26,33,235,236,23])
y =…
I've a big matrix/2D array for which every possible column-pair I need to find the coherence by parallel computation in python (e.g. mpi4py). Coherence [a function] are computed at various child processes and the child process should send the…
I want to slice a 3D array
[-500:500]
to subarrays in sequence 100 subarrays of length 2 then one of length 50 then 100 of length 2 then one of length 50, and I wish every subarray is spaced by length one from the following.
I have two CSV files, both have different numbers of rows and Columns, in File 1, I have the below structure,
PRODUCT NAME
PRODUCT TYPE
PRODUCT SERIAL
Galaxy S6
Android Phone
IAJ83934830485
Surface Pro
Windows Tablet
IM94545435493
iPhone…
I have used numpy to split a string at each ,. The output shows the split words. When I want to retrive first element, I get the following error:
IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed.
Code
item =…
I made a simple array X like this one
import numpy as np
X=np.arange(1,10).reshape(3,3)
Then I made these two arrays that give me the exact same output by slicing X
A=X[:2,:2]
B=X[np.array([0,1])[:,np.newaxis],[0,1]]
If I change a value in A…
Problem:
I have a numpy array of 4 dimensions:
x = np.arange(1000).reshape(5, 10, 10, 2 )
If we print it:
I want to find the indices of the 6 largest values of the array in the 2nd axis but only for the 0th element in the last axis (red circles…