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
   one_mon_hist.mean()

Out[119]:
   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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.