Quick way to check if the pandas series contains a negative value

Krzysztof Słowiński picture Krzysztof Słowiński · Aug 7, 2018 · Viewed 10.5k times · Source

What is the quickest way to check if the given pandas series contains a negative value.

For example, for the series s below the answer is True.

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

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

Answer

Sunitha picture Sunitha · Aug 7, 2018

Use any

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