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

Today Walkin 14th-Sept

Network Error and Timeout on Authorize.net JS

Spring Elasticsearch Operations