# [Numpy-discussion] Extracting individual columns in Numpy (suchith)

Juan fiolj at yahoo.com
Thu Oct 9 08:50:33 EDT 2014

```> Date: Thu, 09 Oct 2014 11:12:31 +0530
> From: suchith <suchithjn22 at gmail.com>
> Subject: [Numpy-discussion] Extracting individual columns in Numpy
> To: numpy-discussion at scipy.org
> Message-ID: <54362047.10102 at gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> How to extract individual columns from a numpy array?
> For example, consider this script
>
> import numpy as np
> a = np.array([[1,2,3],[4,5,6],[7,8,9]])
> a[:]
> a[:]
>
> Now both a[:] and a[:] are outputting the same result, i.e
> np.array([1,2,3]). If I want to extract the array [,,] then
> what should I do? Is it possible to add this feature? If so, which
> file(s) should I edit?
>
> I know C,C++ and Python programming and I am new to open-source software
>
Try:

In : import numpy as np

In : a = np.array([[1,2,3],[4,5,6],[7,8,9]])

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

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

In : a[0,:]
Out: array([1, 2, 3])

In : a[:,0]
Out: array([1, 4, 7])

Syntax is different for numpy arrays.
Regards,
Juan

```