python slice second element of list of lists 1

python slice second element of list of lists

import numpy as np

A = np.array([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]])
A[:,:3]

Out[3]: 
array([[1, 2, 3],
       [1, 2, 3],
       [1, 2, 3]])

Here is what the above code is Doing:
1. A[:,:3] is selecting all rows and the first 3 columns.
2. A[:,:3] is selecting all rows and the first 3 columns.
3. A[:,:3] is selecting all rows and the first 3 columns.

Similar Posts