Answers for "pd average of row range"

2

average out all rows pandas

df.mean(axis=0)#average for each column
df.mean(axis=1)#average for each row
Posted by: Guest on May-20-2020
0

pandas average every n rows

# 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()
Posted by: Guest on September-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language