Trust you all are doing well!
I have this dataframe that contains 0 and float numbers in column ('BP_MOVE') , there could be two conditions
- Zero in any row of column ('BP_MOVE')
- Zero in each row of column ('BP_MOVE')
Below is what i have tried, the first python statement covers the second case very well where each row has 0 value but it fails to cover the first case. similarly, the second python statement gives the following error, is there a way to hit two targets with one arrow ?
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
if (df['bp_move'] == 0).all():
if (df == 0).any(axis=1):
CodePudding user response:
As the comment fros mosc9576 said, you can apply the same syntax you had int the .all()
if (df['bp_move'] == 0).all():
print('all')
if (df['bp_move'] == 0).any():
print('any')