pandas csv sum column
df["column_name"].sum()
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)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us