Performing numerical methods on pandas objects
pandas provides a rich set of functions and operations that facilitate the ability to perform arithmetic operations and to calculate various numerical characteristics of data. In this section, we will examine many of these, including:
- Performing arithmetic on a DataFrame or Series
- Getting the counts of values
- Determining unique values (and their counts)
- Finding minimum and maximum values
- Locating the n-smallest and n-largest values
- Calculating accumulated values
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...