Skip to content

Instantly share code, notes, and snippets.

@skaae
Created September 30, 2015 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skaae/960d2ea96a533bb95ed3 to your computer and use it in GitHub Desktop.
Save skaae/960d2ea96a533bb95ed3 to your computer and use it in GitHub Desktop.
# Initialize column sums
column_sums = [0., 0.]
# Iterate over all rows
for row in row_list:
# For each of the two column values, add to the corresponding sum
column_sums[0] += row[0]
column_sums[1] += row[1]
# Calculate the average by dividing by the length
column_avgs = [column_sums[0]/float(len(row_list)),
column_sums[1]/float(len(row_list))]
print "Column averages: ", column_avgs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment