2021年3月5日星期五

calculate column values based on values of other columns in pandas [closed]

want to calculate C based on values of count, A and B

sample df:

count A B C
yes 23 2 nan
nan 23 1 nan
yes 41 6 nan

result I want

count A B C
yes 23 2 46
nan 23 1 0
yes 41 6 624

that is, it should skip nan values of count

Any help is appreciable

https://stackoverflow.com/questions/66496782/calculate-column-values-based-on-values-of-other-columns-in-pandas March 06, 2021 at 01:12AM

没有评论:

发表评论