how do I get arrays x and y from array a?
a is a 2d array and I need to get x and y which are the columns of a
a=[[ 0 1]
[ 2 3]
[ 4 5]
[ 6 7]
[ 8 9]
[10 11]]
x =[[0]
[2]
[4]
[6]
[8]
[10]]
y = [[1]
[3]
[4]
[7]
[9]
[11]]
your array:-
arr=np.array([[0,1],[2,3],[4,5],[6,7],[8,9],[10,11]])
your answer:-
arr1,arr2=np.split(arr,2,axis=1)
Try this
numpy.split(array, 2, axis=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With