Issue
I would like to sum by only negative numbers across all the columns in a dataframe.
I have seen this post: Pandas: sum up multiple columns into one column
My data looks like this:
But I would like to sum only the negative numbers. How do i do that?
Solution
Using mask
df.iloc[:,1:].where(df.iloc[:,1:]<0).sum(axis=1)
Answered By - BENY
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.