Skip to content
Advertisement

Calculating the average value for every 10 cells in each column by pandas

In my excel csv files, there are around 1500 rows and 30 columns. I believe I can use python to complete it. so here is my target:

  1. How to let python read my excel file correctly.
  2. I want to reduce the number of rows to 1/10, so How can I calculate the average value for every 10 rows in each column?
  3. At the same time, I hope to keep the timeslot column so I understand what period it indicates.

Here is my excel file in short. enter image description here

I have uploaded the file on Google Drive, please try to have a look https://drive.google.com/file/d/1EDmSgsEoNQYZeRD_JiR33WNv7ENW4cp3/view?usp=sharing

The code I used is shown below

JavaScript

Advertisement

Answer

This code would clean your data and take the mean for every 10th row.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement