我有一台Pandas 数据帧(见下文).我正在try 找到一种快速(且简洁)的方法来生成包含布尔值的列d,如果相应行中的a、b或c中的任何一个为True,则为真.without using a for loop.我只是不能用矢量化让它工作. 提前谢谢!
我的数据帧:
a | b | c |
---|---|---|
True | False | True |
False | True | False |
False | False | False |
我试过的是:
我try 使用any(),但如果the entire frame中的任何值等于True,则计算结果为True.
我还设法使用for循环获得了正确的结果,并对每一行应用any(),但在一定数量的行之后,这太慢了.
edit: fixed table formatting个