O'Reilly logo

Learning pandas 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

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 ...

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