How to transpose a list of lists in Python

Transposing a list of lists results in a new list of lists with “columns” of the original list as its “rows” and “rows” of the original list as its “columns”.

Solution for How to transpose a list of lists in Python : You can use numpy.T to transpose a list of lists Call numpy.array(object) to convert the list of lists object to a numpy.ndarray. Call arr.T with arr as the previous result to transpose arr. Call numpy.ndarray.tolist() with numpy.ndarray as the previous result to convert numpy.ndarray to a list.


how-to-transpose-a-list-of-lists-in-python