Chapter 2. NumPy Basics

After installing NumPy and getting some code to work, it's time to cover NumPy basics. This chapter introduces you to the fundamentals of NumPy and arrays. At the end of this chapter you will have a basic understanding of NumPy arrays and their associated functions.

The topics that we shall cover in this chapter are as follows:

  • Data types
  • Array types
  • Type conversions
  • Creating arrays
  • Indexing
  • Fancy indexing
  • Slicing
  • Manipulating shapes

The NumPy array object

NumPy has a multidimensional array object called ndarray. It consists of two parts as follows:

  • The actual data
  • Some metadata describing the data

The majority of array operations leave the raw data untouched. The only aspect that changes is the metadata.

We have already learned in the ...

Get Learning NumPy Array now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.