Answers for "How to sum a column in Python csv"

0

pandas csv sum column

df["column_name"].sum()
Posted by: Guest on April-29-2021
0

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)
Posted by: Guest on June-01-2021

Code answers related to "How to sum a column in Python csv"

Python Answers by Framework

Browse Popular Code Answers by Language