O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

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

Performing arithmetic on a DataFrame or Series

Arithmetic operations can be performed on a DataFrame (and Series) using the +, -, /, and * operators. While these may seem trivial in nature, pandas adds a powerful twist by performing alignment of the values on the left and right sides of the equations. Hence indexes play a big part in arithmetic, and how this affects the results needs to be understood by the user of pandas.

Additionally, pandas not only provides the standard operators for arithmetic but also provides several methods, .add(), .sub(), .mul(), and .div() , that provide higher performance and greater flexibility in specifying the axes on which to apply the function.

Arithmetic operations using a scalar value will be applied to ...

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