MISSION 508

Broadcasting NumPy Arrays

In the previous mission, we've learned that we can perform arithmetic operations between ndarrays of the same shape.

In this mission, we will learn that these operations can also be performed between ndarrays of different shape, for as long as a set of rules is verified.

In particular, you'll:

  1. Learn how to perform arithmetic operations between ndarrays and values. For example, how to add a fixed value to each entry of an ndarray.
  2. Learn how to perform arithmetic operations between 1-dimensional arrays and 2-dimensional arrays.
  3. Learn how to change the shape of an ndarray.

Now, imagine that we want to increase every entry in an ndarray by one. How do we do that? In this mission, we'll cover that and much more!

As with all Dataquest missions, this is an interactive learning experience. You'll be writing real Python code and using NumPy in our browser-based coding environment so there's no setup and no obstacles between you and learning!

Objectives

  • Learn how to perform arithmetic operations between ndarrays and values.
  • Learn how to change the shape of an ndarray.

Mission Outline

  1. Introduction
  2. Broadcasting with a Single Value
  3. Broadcasting Mental Model
  4. Broadcasting Horizontally
  5. Broadcasting Vertically
  6. Broadcasting on Both
  7. Broadcasting Rules
  8. Reshaping
  9. Compatible Shapes
  10. Next Steps
pandas-fundamentals

Course Info:

Intermediate

This is part of our NumPy for Data Engineers course. View Details.

This course includes five missions. It is the ninth course in the Data Engineer path.

START LEARNING FREE

Take a Look Inside