Home > Net >  Sum every N col and row in python
Sum every N col and row in python

Time:12-01

I have a data list more than 100 row in csv file sth like this:

A B C D E F H
0 9 0 9 0 9 0
0 9 0 0 0 9 0
0 0 0 0 0 9 0
0 0 0 0 0 9 0
0 0 0 0 0 9 0
0 9 0 9 0 9 0
0 9 0 0 0 9 0
0 0 0 0 0 9 0
0 0 0 0 0 9 0
0 0 0 0 0 9 0

I need to sum each 5 cell of a column And write the answer in a new row sth like this will be: Note: its just for the first three column and N = 5:

J K L
0 18 0
0 18 0

The code that i use is below

  • Related