How to sum based on other cols

I'd like to calculate the following sum(size):

sample data

The sum(size) is a sum of col size, and for each col i'd to sum only up the last non-0/NaN row. Is this possible in python?

I've tried to add df.apply(pd.Series.last_valid_index) to identify the last index for each col, but i don't know how to incorporate into the over query to get the sum for each col.



Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept