Python - Calculate average for every column in a csv file

后端 未结 6 945
执笔经年
执笔经年 2020-12-10 20:02

I\'m new in Python and I\'m trying to get the average of every (column or row) of a csv file for then select the values that are higher than the double of the average of its

6条回答
  •  春和景丽
    2020-12-10 20:14

    I suggest breaking this into several smaller steps:

    1. Read the CSV file into a 2D list or 2D array.
    2. Calculate the averages of each column.

    Each of these steps can be implemented as two separate functions. (In a realistic situation where the CSV file is large, reading the complete file into memory might be prohibitive due to space constraints. However, for a learning exercise, this is a great way to gain an understanding of writing your own functions.)

提交回复
热议问题