假设我有一个这样的Pandas 数据帧
name col1 col2 col3
0 AAA 1 0 2
1 BBB 2 1 2
2 CCC 0 0 2
我想要(A)任何包含值2
的列的名称(即,col1
,col3
),以及(B)任何包含only个值为2
的列(即,col3
)的名称.
我了解如何使用DataFrame.any()
和DataFrame.all()
来 Select DataFrame中值出现在任意或所有列中的行,但我正在try 查找值出现在(A)任意行或(B)所有行中的列.