xxxxxxxxxx
df.mean(axis=0)#average for each column
df.mean(axis=1)#average for each row
xxxxxxxxxx
# credit to the Stack Overflow user in the source link
# df is the pandas DataFrame
n = 25 # the number of rows
df.groupby(np.arange(len(df))//n).mean()
xxxxxxxxxx
df['mean'] = df.mean(axis=1)
>>> df
Y1961 Y1962 Y1963 Y1964 Y1965 Region mean
0 82.567307 83.104757 83.183700 83.030338 82.831958 US 82.943612
1 2.699372 2.610110 2.587919 2.696451 2.846247 US 2.688020
2 14.131355 13.690028 13.599516 13.649176 13.649046 US 13.743824
3 0.048589 0.046982 0.046583 0.046225 0.051750 US 0.048026
4 0.553377 0.548123 0.582282 0.577811 0.620999 US 0.576518