Description

The DataFrame provides many functions that show description operations, such as mean, median, and sum, that help you get a feel for the data.

For these functions, the default operations are performed column-wise. If you want to do row-wise operations, you can pass the parameter axis=1 to those functions.

mean

Calculate the mean of column or row. In the code below, there is a function called describe() that gives you mean, count, minimum and maximum values, three quartiles, and the standard deviation. This is very useful when you are in exploratory data analysis.

Press + to interact
import pandas as pd
# create a matrix, the size is 10*3
d = {"a":range(1, 10), "b": range(11,20), "c": range(21,30)}
df = pd.DataFrame(d)
print("---------------------------")
# calculate the mean of each column
print("The mean of each column is {}".format(df.mean().values))
# calculate the mean of each row
print("The mean of each row is {}".format(df.mean(axis=1).values))
# give a summary of your data on column wise
print(df.describe())

Line 8 ...

Access this course and 1400+ top-rated courses and projects.