I am trying to determine if two variables are found in the dataframe
table:
Code index
600.SI 4th Q 2015
500.SI Full Year
ggr.SI 1st Q 2016
# If variable_code and variable_date is not found in table, print not found
if table['Code'].str.contains(variable_code).any() & table['index'].str.contains(variable_date).any():
print('found')
else:
print('not found')
However, it always return me found
.
I think my if
statement is structured incorrectly to do a bool
comparison for two items.
How can this be solved?
Update
Normally, variable_code
will be found in table
. if variable_code
is found in table
, check if variable_date
is present too.
What I am trying to achieve is, If both of these conditions are not present, print not found
.