Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to sum a column in Python csv

import pandas as pd
data = pd.read_csv('pandas.csv')
df = pd.DataFrame(data)
id_sum = 0
data_sum = 0
for i in range(len(df)):
   if(i==len(df)-2 or i==len(df)-1):
      id_sum = id_sum + df.iloc[i][0]
      data_sum = data_sum + df.iloc[i][1]
print("Id",id_sum)
print("Data",data_sum)
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #How #sum #column #Python #csv
ADD COMMENT
Topic
Name
8+2 =