print("Data : ", df)
print("Value: ", (df < 0).any())
Data : 1 2 3 0 0.000000 NaN NaN 1 11.874342 NaN NaN 2 2.236068 NaN NaN 3 12.041595 11.313708 NaN 4 2.236068 -11.400000 12.165525 Value: 1 False 2 True 3 False dtype: bool
我不明白为什么它为每一列返回布尔值?
答案 0 :(得分:3)
由于any
的默认值沿索引轴减小,请参见文档:https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.any.html
如果您指定any(axis=None)
,则 会减少为标量,在您的情况下为True