Answers for "convert this from a 2D to a 1D array numpy"

C++
1

array 2d to 1d

int array[width * height];

 int SetElement(int row, int col, int value)
 {
    array[width * row + col] = value;  
 }
Posted by: Guest on January-28-2020
0

pass 2d array to 1d python

# Create a 2D Numpy Array.
arr = np. array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
# convert 2D array to a 1D array of size 9.
flat_arr = np. reshape(arr, 9)
Posted by: Guest on June-08-2021

Browse Popular Code Answers by Language