Calculating the mean

The mean, commonly referred to as the average, gives us a measurement of the central tendency of data. It is determined by summing up all the measurements and then dividing by the number of measurements.

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

Pandas has taken each column and independently calculated the mean for each. It returned the results as values in a Series that is indexed with the column names. The default is to apply the method on axis=0, applying the function to each column. This code switches the axis and returns the average price for all stocks on each day:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset