Let's say that I have two tables: people_all and people_usa, both with the same structure and therefore the same primary key.
How can I get a table of the people not in the USA? In SQL I'd do something like:
select a.*
from people_all a
left outer join people_usa u
on a.id = u.id
where u.id is null
What would be the Python equivalent? I cannot think of a way to translate this where statement into Pandas syntax.
The only way I can think of is to add an arbitrary field to people_usa (e.g. people_usa['dummy']=1), do a left join, then take only the records where 'dummy' is nan, then delete the dummy field - which seems a bit convoluted.
people_all_set.difference(people_usa_set)do the trick?differenceoperates on indexes so it would need to bepeople_all_set.index.difference(people_usa_set.index)pandas.pydata.org/docs/reference/api/…