Working with arrays

Once NumPy arrays are created or loaded, there are basically three things that we can do with them:

  • Selection
  • Manipulation
  • Computation


Selection consists of accessing one or several elements within an array. It can be done with NumPy or Pandas.

Using Pandas

Let's continue with our example data opened with Pandas. Each column of the data object of DataFrame can be accessed through its name. In IPython, tab completion proposes the different columns of the data. In the following example, we get the names of all cities (AccentCity is the full name of the city, with uppercase characters and accents):

In [15]: data.AccentCity
0                  Aixas
1             Aixirivali
3173956              Zuzumba
3173957           Zvishavane
Name: AccentCity, Length: 3173958 ...

Get Learning IPython for Interactive Computing and Data Visualization now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.