I am trying to convert a sql query to python. The sql statement is as follows:
select * from table 1
union
select * from table 2
union
select * from table 3
un
This should be a comment on Jezrael's answer (+1'd for merge
over concat
) but I haven't sufficient reputation.
The OP asked how to union
the dfs, but merge
returns intersection
by default:
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.merge.html#pandas.merge
To get union
s, add how='outer'
to the merge
calls.