Horje
convert 2d aray into 1d using python Code Example
convert 2d list to 1d python
import itertools

a = [[1, 2], [3, 4], [5, 6]]
list(itertools.chain.from_iterable(a))

Output:- [1, 2, 3, 4, 5, 6]
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)
convert 2d aray into 1d using python
import numpy as np

twoDAry = [6.4],[5.9],[5.5],[5.3],[5.1],[4.9],[4.5],[4.5],[4.5],[4.3],[4.2],[3.8],[3.5],[2.8],[2.8],[2.8]
twoDAry = np.array(twoDAry)
print(twoDAry.reshape(1, -1)[0])

# Output
# [6.4 5.9 5.5 5.3 5.1 4.9 4.5 4.5 4.5 4.3 4.2 3.8 3.5 2.8 2.8 2.8]




Python

Related
programe to find contagious sum of sequence Code Example programe to find contagious sum of sequence Code Example
getting player input python Code Example getting player input python Code Example
form is undefined flask Code Example form is undefined flask Code Example
What is the purpose of open ( ) and close ( )  in os Code Example What is the purpose of open ( ) and close ( ) in os Code Example
trim all new rows string python Code Example trim all new rows string python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7