Math

Of course, mathematical operations are well present in pandas, which actively leverages NumPy's functionality and supports an extra-wide specter of math and statistical functionality. To get a sum, mean, median, max/min, or percentile of a numerical column, just call it as a column's method:

>>> N = pd.Series([1,2,3,10])

>>> N.mean()
4.0

>>> N.median()
2.5

>>> N.sum()
16

>>> N.max()
10

It also supports operations such as correlation (just call it on another numeric column of the same length), and many more. Most of the time, you can run the very same functions on the dataframes—in this case, axis (direction of operation) will be used as an argument. The default, all operations are run vertically—for example, for df.sum() you will get a series of sums, one for each column in the original dataframe. The very same operations with axis=1 will summarize every row, so you will get Series with a cell for each row in the dataframe.

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

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