I'm trying to do something with pandas equivalent to the following SQL command:
select *
from tableA as A
left join tableB as B
on A.key = B.key and substr(A.value,1,2) not in ('something', 'something else')
As you can see in the sql query above, A.value have a filter condition applied during the join, but since it's a left join, the on condition not in criteria does not persist to the result dataset, it only applies during the join operation, such that the join operation will not consider any rows fulfilling the A.value not in ('something', 'something else') criteria.
I tried the following python code, but it results in filtering out the A.value rows from the result dataset, I need all the rows via the left join, but i don't want the merge operation on the rows as specified by the a.value not in condition, just like the SQL statement logic above.
df_output = df_input1[~df_input1['value'].str[:2].isin(['something', 'something_else'])].merge(df_input2, left_on = 'key', right_on = 'key', how='left')
Thank you all in advance!