multidimensional-array

MinmaxScaler: Normalise a 4D array of input

MinmaxScaler: Normalise a 4D array of input Question: I have a 4D array of input that I would like to normalise using MinMaxScaler. For simplicity, I give an example with the following array: A = np.array([ [[[0, 1, 2, 3], [3, 0, 1, 2], [2, 3, 0, 1], [1, 3, 2, 1], [1, 2, 3, …

Total answers: 3

Add third dimension to a 2-dimensional numpy.ndarray

Add third dimension to a 2-dimensional numpy.ndarray Question: I have an array which contains 50 time series. Each time series has 50 values. The shape of my array is therefore: print(arr.shape) = (50,50) I want to extract the 50 time series and I want to assign a year to each of them: years = list(range(1900,1950)) …

Total answers: 1

3D numpy array MinMax Normalization

3D numpy array MinMax Normalization Question: I’d like to MinMax normalize the following 3D numpy array "at 2D-layer level" : np.array([[[0, 1, 2], [3, 4, 5], [6, 7, 8]], [[0, 1, 2], [3, 4, 5], [6, 7, 10]], [[0, 1, 2], [3, 4, 5], [6, 7, 12]]]) to obtain : np.array([[[0. , 0.1, 0.2], [0.3, …

Total answers: 2

MinMax scaling on numpy array multiple dimensions

MinMax scaling on numpy array multiple dimensions Question: How to minmax normalize in the most efficient way, a XD-numpy array in "columns" of each 2D matrix of the array. For example with a 3D-array : a = np.array([[[ 0, 10], [ 20, 30]], [[ 40, 50], [ 60, 70]], [[ 80, 90], [100, 110]]]) into …

Total answers: 3

How to stack summing vectors to numpy 3d array?

How to stack summing vectors to numpy 3d array? Question: I have a 3d numpy array that looks like so: >>> g array([[[ 1., 1., 1., 1., 1.], [ 0., 0., 0., 0., 0.], [ 1., 2., 3., 4., 6.]], [[ 0., 0., 0., 0., 0.], [11., 22., 33., 44., 66.], [ 0., 0., 0., …

Total answers: 2

How to turn a 3d numpy array into a pandas dataframe of numpy 1d arrays?

How to turn a 3d numpy array into a pandas dataframe of numpy 1d arrays? Question: I have a numpy 3d array. I’d like to create a pandas dataframe off of it which would have as many rows as the array’s 1st dimension’s size and the number of columns would be the size of the …

Total answers: 1

Nested structured array to pandas dataframe with new column names

Nested structured array to pandas dataframe with new column names Question: How can I convert/explode a nested numpy structured array into a pandas dataframe, while keeping the headers from the nested arrays? Using Python 3.8.3, numpy 1.18.5, pandas 1.3.4. Example structured array: I am given a nested numpy structured array that looks like this, and …

Total answers: 1

Numpy: Using an index array to set values in a 3D array

Numpy: Using an index array to set values in a 3D array Question: I have an indices array of shape (2, 2, 3) which looks like this: array([[[ 0, 6, 12], [ 0, 6, 12]], [[ 1, 7, 13], [ 1, 7, 13]]]) I want to use these as indices to set some values of …

Total answers: 1

Object fields in 2d array seemingly change for no reason?

Object fields in 2d array seemingly change for no reason? Question: I am creating a 2d array of square objects. Each square needs to be displayed in a window, so I need to iterate x and y by the width of a square and save those x and y values in the square object. In …

Total answers: 1