O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Advanced Indexing and Array Concepts

In this chapter, we will cover the following recipes:

  • Installing SciPy
  • Installing PIL
  • Resizing images
  • Comparing views and copies
  • Flipping Lena
  • Fancy indexing
  • Indexing with a list of locations
  • Indexing with Booleans
  • Stride tricks for Sudoku
  • Broadcasting arrays

Introduction

NumPy is famous for its efficient arrays. This fame is partly due to the ease of indexing. We will demonstrate advanced indexing tricks using images. Before diving into indexing, we will install the necessary software—SciPy and PIL. If you feel it is required, review the Installing matplotlib recipe in Chapter 1, Winding Along with IPython.

In this chapter and in other chapters, we will use the following imports:

import numpy as np import matplotlib.pyplot ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required