詹惠儿

2021-01-08   阅读量: 634

Python

pandas中表连接的pd.concat()和pd.merge()在使用场景下有什么不同?

扫码加入数据分析学习群

问:

pandas中表连接的pd.concat()和pd.merge()在使用场景下有什么不同?

pd.concat(    ['objs', 'axis=0', "join='outer'", 'join_axes=None', 'ignore_index=False', 'keys=None', 'levels=None', 'names=None', 'verify_integrity=False', 'sort=None', 'copy=True'],)
pd.merge(    ['left', 'right', "how='inner'", 'on=None', 'left_on=None', 'right_on=None', 'left_index=False', 'right_index=False', 'sort=False', "suffixes=('_x', '_y')", 'copy=True', 'indicator=False', 'validate=None'],)


答:

当需要同时连接多个表,且不分左右表时用pd.concat(),pd.concat()可设置内连接或者外连接,

但是不区分左右表,当需要考虑表连接的主表时用pd.merge(),pd.merge()更类似于sql中的表

连接,支持设置左连接,右连接,内连接和外连接。

80.0000 1 0 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子