问题
For a given series, e.g.
s = pd.Series([0,0,0])
I would like to check whether ALL elements in this series are equal to a specific value (we can use 0 in this example) and return TRUE if that is the case, and FALSE otherwise.
is there a handy way to do those in Pandas/numpy?
回答1:
You should use the following syntax:
s = pd.Series([0,0,0])
print(s.eq(0).all())
True
回答2:
Another way to do the same would be:
print((s==0).all())
来源:https://stackoverflow.com/questions/58359706/how-to-check-whether-all-elements-in-a-pandas-series-are-equal-to-a-specific-val