Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how get 1st column in all rows of a 2d matrix in python

data = [
['a', 1, 2], 
['b', 3, 4], 
['c', 5, 6]
]

columns = list(zip(*data))

print("column[0] = {}".format(columns[0]))
print("column[1] = {}".format(columns[1]))
print("column[2] = {}".format(columns[2]))

# output
>>> print("column[0] = {}".format(columns[0]))
column[0] = ('a', 'b', 'c')

>>> print("column[1] = {}".format(columns[1]))
column[1] = (1, 3, 5)

>>> print("column[2] = {}".format(columns[2]))
column[2] = (2, 4, 6)
Comment

PREVIOUS NEXT
Code Example
Python :: finding random numbers python 
Python :: python get screen size raspberry pi 
Python :: how to find avrage python 
Python :: discord.py setup_hook 
Python :: how to use css in php example 
Python :: if a list has a string remove 
Python :: random normal 
Python :: python checking for NoneType 
Python :: DJANGO rest framework GET POST 
Python :: create virtualenv python3 
Python :: get method in python 
Python :: python bisect 
Python :: pycharm update python version 
Python :: arrayfield in django 
Python :: matplotlib legend number columns 
Python :: matplotlib plot in second axis 
Python :: python package structure 
Python :: find greatest number in list python 
Python :: character in string python 
Python :: appending to a list python 
Python :: python string formatting 
Python :: turtle 
Python :: python list of dictionaries to list 
Python :: python do while loop 
Python :: sympy 
Python :: sns histplot nan values 
Python :: power in python 
Python :: python generator expression 
Python :: best scraping package in python 
Python :: python string replace variable 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =