np.where

https://blog.csdn.net/erinapple/article/details/80838359

 

 三目运算符:

tmp = data.assign(**{'ws^2': data.apply(lambda row: sum(row['ws'] * np.where(
row['factor'] == data['factor'], data['ws'], 0.0)), axis=1)})
posted @ 2022-01-10 16:23  ivyJ  阅读(72)  评论(0)    收藏  举报