It’s easy to select a part of dataframe by one condition like below.
pos
= df_train
[df_train
['Date']>0]
But when you are trying to add conditions like this
pos
= df_train
[df_train
['Date']>0 and df_train
['Coupon_id']>0]
You get error like this.
ValueError
: The truth value of a Series
is ambiguous
. Use a
.empty
, a
.bool(), a
.item
(), a
.any() or a
.all().
The right way to write it
pos
= df_train
[(df_train
['Date']>0) & (df_train
['Coupon_id']>0)]
[1]: https://blog.csdn.net/destiny_python/article/details/78675036