I have a large CSV file with two columns in it as shown below:
I have already filtered the data. I need to calculate the average pressure every x amount of rows.
I've looked for a while on here but was unable to find how to calculate the average every x amount of rows for a specific column. Thanks for any help you can provide.
CodePudding user response:
n = 3
x = df['Pressure']
# calculates the average
avgResult = np.average(givenArray.reshape(-1, n), axis=1)
the result is array, which divide columns into n sets:
eg:
array([3.33333333, 4.66666667])
in:
n=3
x = np.array([1, 4, 5,2,8,4])