[Python] How to access a column in a list of lists in python

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have a 2D array in python modeled by a list of lists and I want to extract the column. I made a quick research and I found a way that uses numpy arrays. The problem is that I do not want to use numpy so I don't want to convert my list of lists into a numpy array and then use [:,1] syntax. I tried using it on a normal list of lists but it shows an error so it's not possible. I am asking for a similar thing for list of lists without having to go through each element (In numpy arrays, it's faster to access a column by using [:,1] syntax than iterating over the elements of the array).

    I found this link but again it suggests iterating over elements without a shortcut.

    Continue reading...

Compartilhe esta Página