How to sum a column in Python csv code example
Example 1: pandas csv sum column
df["column_name"].sum()
Example 2: 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)