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
4 RĂ©ponses
+ 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