首先把官网的用法过一遍
1、DataFrame.any(axis=0, bool_only=None, skipna=True, level=None, **kwargs)
Return whether any element is True over requested axis.
只要选中的维度中有一个真值则返回真
>>> df = pd.DataFrame({
"A": [0, 2], "B": [0, 2], "C": [0, 0]})
>>> df
A B C
0 0 0 0
1 2 2 0
>>> df.any()#列求真
A True
B True
C False####看这里,C列都为0,所以返回False
dtype: bool
>>> df.any(axis='columns')#行求真
0 False#看这里,第一行都为0,所以返回False
1 True
dtype: bool
2、DataFrame.drop(labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors=’raise’)
Drop specified labels from rows or columns.
丢弃掉指定的行或者列
#接着上面的例子
>>> s = df.drop([0])#把第一行丢弃掉
>>> s
A B C
1 2 2 0
>>> df.drop(columns=['B','C'])#把B、C列丢弃掉
A
0 0
1