Summarized data and descriptive statistics

pandas provides several classes of statistical operations that can be applied to a Series or DataFrame object. These reductive methods, when applied to a Series, result in a single value. When applied to a DataFrame, an axis can be specified and the method will then be either applied to each column or row and results in a Series.

The average value is calculated using .mean(). The following calculates the average of the prices for AAPL and MSFT:

In [119]:
   # calc the mean of the values in each column

   MSFT     47.493182
   AAPL    112.411364
   dtype: float64

pandas has taken each column and independently calculated the mean for each and returned the results as values in a Series that ...

Get Learning pandas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.