df.mean(axis=0)#average for each column df.mean(axis=1)#average for each row
# 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()