Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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]
Comment

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]
Comment

PREVIOUS NEXT
Code Example
Python :: transparancy argument pyplot 
Python :: segregate list in even and odd numbers python 
Python :: crop image python 
Python :: python project ideas 
Python :: chrome selenium python 
Python :: python how to get every name in folder 
Python :: numpy ones 
Python :: python multiply list bt number 
Python :: return column of matrix numpy 
Python :: matplotlib set number of decimal places 
Python :: discord embed add image 
Python :: python every other goes to a list 
Python :: how to make a never ending loop in python 
Python :: button in flask 
Python :: matplotlib create histogram edge color 
Python :: pd max rows set option 
Python :: reverse shell python 
Python :: pyqt latex 
Python :: python sftp put file 
Python :: how to get user ip in python 
Python :: pyhton turtle delete 
Python :: pandas to tensor torch 
Python :: pandas replace nan 
Python :: get information about dataframe 
Python :: how to reverse array in ruby 
Python :: python datetime last day of month 
Python :: python list distinct 
Python :: openpyxl get last non empty row 
Python :: python filter a dictionary 
Python :: Python - Drop row if two columns are NaN 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =