Answers for "take the average of 3 rows to make 1 row pandas"

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

Code answers related to "take the average of 3 rows to make 1 row pandas"

Python Answers by Framework

Browse Popular Code Answers by Language