Re: numpy array question

2020-04-02 Thread Peter Otten
jagmit sandhu wrote: > python newbie. I can't understand the following about numpy arrays: > > x = np.array([[0, 1],[2,3],[4,5],[6,7]]) > x > array([[0, 1], >[2, 3], >[4, 5], >[6, 7]]) > x.shape > (4, 2) > y = x[:,0] > y > array([0, 2, 4, 6]) > y.shape > (4,) > > Why is t

Re: numpy array question

2020-04-02 Thread edmondo . giovannozzi
Il giorno giovedì 2 aprile 2020 06:30:22 UTC+2, jagmit sandhu ha scritto: > python newbie. I can't understand the following about numpy arrays: > > x = np.array([[0, 1],[2,3],[4,5],[6,7]]) > x > array([[0, 1], >[2, 3], >[4, 5], >[6, 7]]) > x.shape > (4, 2) > y = x[:,0] > y

numpy array question

2020-04-01 Thread jagmit sandhu
python newbie. I can't understand the following about numpy arrays: x = np.array([[0, 1],[2,3],[4,5],[6,7]]) x array([[0, 1], [2, 3], [4, 5], [6, 7]]) x.shape (4, 2) y = x[:,0] y array([0, 2, 4, 6]) y.shape (4,) Why is the shape for y reported as (4,) ? I expected it to be a