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 :: how to find the shortest word in a list python 
Python :: extract all file in zip in python 
Python :: make guessing game by python 
Python :: pandas dataframe total column 
Python :: printing first n prime numbers 
Python :: selenium python element id 
Python :: Following Links in Python 
Python :: group normalization 
Python :: python program to find sqaure root of the number 
Python :: hur många partier sitter i riksdagen 
Python :: analyse des fleurs du mal la vision du baudelaire 
Python :: how to use visualize_runtimes 
Python :: python while loop and recursion 
Python :: Checking Availability of user inputted File name 
Python :: keylogger to exe 
Python :: how to add twoo segmen time series in a single plot 
Python :: line continutation in r string python 
Shell :: remove steam from ubuntu 
Shell :: stop nginx ubuntu 
Shell :: refusing to merge unrelated histories 
Shell :: install dateutil 
Shell :: git username email 
Shell :: check chrome version ubuntu via terminal 
Shell :: conda install ipywidgets 
Shell :: install material ui 
Shell :: stop all container in docker 
Shell :: failed to load module canberra-gtk-module 
Shell :: uninstall apache2 ubuntu 20.04 
Shell :: restart crontab 
Shell :: flush dns bash 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =