我正在尝试将sql查询转换为python。sql语句如下:
select * from table 1
union
select * from table 2
union
select * from table 3
union
select * from table 4
现在我在4个dataframedf1, df2, df3, df4
中有了这些表,我想联合4个pandas dataframe,它将与sql查询结果匹配。
我搞不清要使用什么操作,它相当于sql union?
提前谢谢!!
注: 所有数据帧的列名都相同。
这应该是对耶兹雷尔的回答的一个评论,我没有足够的声誉。
OP询问如何
union
dfs,但是merge
默认返回intersection
: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.merge.html#pandas.merge要获取
union
s,请将how='outer'
添加到merge
调用中。相关问题 更多 >
编程相关推荐