make a new 2d array with only first and third columns of this matrix. in python

main.py
import numpy as np

# Assuming `matrix` is your initial 2D array
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

# Extracting the first and third columns
new_array = matrix[:, [0, 2]]

print(new_array)
208 chars
10 lines

related categories

gistlibby LogSnag