I have a bit of a problem that I'm having trouble solving. My company has a bunch of legacy SAS code that they're converting to a combination of Python and SQL. And there is a merge in some Proc SQL code that I can't figure out how to correctly translate to Python. Here is the code:
proc sql;
select
... (skipping through irrelevant parts)
from main_data
left join joined_data on main_data.account = joined_data.account
AND joined_data.ID ne ''
and ((joined-data.source in ('option1','option2')
and main_data.num in ('123','456','789'))
or (joined_data.source in ('option3') and main_data.num in ('101112')))
Keep in mind that the data will be stored in pandas data frames. The first part of the join (account=account) is easy to do through pd.merge, but I'm a bit stumped on how to mimic the second part in python.
Thanks for the help!