Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas csv sum column

df["column_name"].sum()
Comment

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)
Comment

PREVIOUS NEXT
Code Example
Python :: can i call a python script from a function 
Python :: BST_Deleting 
Python :: decimal hour to hour minute python 
Python :: how to use histogram in python 
Python :: copy along additional dimension numpy 
Python :: Python program to count Even and Odd numbers using while loop in a List 
Python :: add a row at a specific index pandas 
Python :: how to use with statementin python 2.4 
Python :: random list 
Python :: create database tables python 
Python :: drop duplicates columns pandas 
Python :: python menentukan genap ganjil 
Python :: pandas data frame from part of excel 
Python :: explode multiple columns pandas 
Python :: get image image memeory size in url inpyton requests 
Python :: number string array 
Python :: algebraic pyramid python 
Python :: cin python 
Python :: NumPy resize Syntax 
Python :: where are docker logs 
Python :: pyton count senteses in a text file 
Python :: open textfile separated by whitespaces python 
Python :: assignment 6.5 python for everybody 
Python :: discord embed python 
Python :: create an array filled with 0 
Python :: read csv in spark 
Python :: node 14 alpine add python 
Python :: how to find min, max in dictionaries 
Python :: how to create a function in python 
Python :: python background process 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =