我有两个行向量。基于行向量之一的最大值,我想从另一个向量中的对应列中减去1,然后将1 /(n-1)加到每个其他列中。除了最后一步,我可以做所有事情。是否有一个表达式可以做到这一点?请参阅下文,了解我的位置:
>>> weights
AST L/S LCG AST TRP LCG AST Jenn LCG AST MFS LCG
0 2 33.98 8.69 21.2
>>> mContrib
AST L/S LCG AST TRP LCG AST Jenn LCG AST MFS LCG
0 0.319689 0.254385 0.289225 0.136701
>>> weights[mContrib.idxmax(axis=1)] = weights[mContrib.idxmax(axis=1)] - 1
>>> weights
AST L/S LCG AST TRP LCG AST Jenn LCG AST MFS LCG
0 1 33.98 8.69 21.2
>>> #need expression that will add 1/(n-1) to each of the other columns