Axis usage examples

In the axis usage examples, we calculate the mean for the values in the dataset. We have passed axis as 0. This means that the mean will be calculated along the row axis, as follows:

data.mean(axis=0) 

The following is the output:

Next, we set axis to 1. We are using the exact same method on the same dataset; however, we are changing axis from 0 to 1. Since we set axis to 1, the mean has been calculated along the columns:

data.mean(axis=1).head() 

The following is the output:

Sometimes it's difficult to remember whether ...

Get Mastering Exploratory Analysis with pandas now with O’Reilly online learning.

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