gpt4 book ai didi

python - 快速检查 Pandas 系列是否包含负值的方法

转载 作者:太空狗 更新时间:2023-10-30 01:56:31 27 4
gpt4 key购买 nike

检查给定 pandas 系列是否包含负值的最快方法是什么。

例如,对于下面的系列 s,答案是 True

s = pd.Series([1,5,3,-1,7])

0 1
1 5
2 3
3 -1
4 7
dtype: int64

最佳答案

使用任意

>>> s = pd.Series([1,5,3,-1,7])
>>> any(s<0)
True

关于python - 快速检查 Pandas 系列是否包含负值的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51720780/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com