0

How can I find sum till a certain row in a python pandas dataframe?

Python Dataframe using Pandas Library

21st Jul 2020, 5:10 PM
Pankaj Kumar Malviya
Pankaj Kumar Malviya - avatar
3 Answers
+ 1
Pankaj Kumar Malviya , Here i did sum of the all passengers whose Fare is lessthan8 by adding extra column. import pandas as pd df = pd.read_csv('https://sololearn.com/uploads/files/titanic.csv') df['lessthan8']= df['Fare'] < 8 is_less_8 = pd.Series(df['lessthan8']) print(sum(df[is_less_8]['Fare'].values))
21st Jul 2020, 5:31 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
Let's say I have 1 column of some int data and other column for data I want to sum the data till a certain date
21st Jul 2020, 5:15 PM
Pankaj Kumar Malviya
Pankaj Kumar Malviya - avatar
0
♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ It is working for me. I don't know why not for you. Please don't tag me if it works or not works, it is just a sample code.
21st Jul 2020, 6:08 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar