I am trying to use multiple conditions in my pandas, but I am getting the following error:
ValueError: The truth value of a Series is ambiguous. Use a.empty,
a.bool(), a.item(), a.any() or a.all().
As per this thread I replaced the and
with a bitwise operator, but I am still getting the error.
import pandas as pd
d1 = {'Year': [2019,2019,2019,2019,2019], 'Week':[1,2,4,6,7], 'Value':
[20,40,60,75,90]}
df1 = pd.DataFrame(data=d1)
if (df1['Year'] == df1['Year'].shift(-1)) & \
(df1['Week'] == df1['Week'].shift(-1)):
print('Yes')
else:
print('No')
What might I be doing wrong here?