【Pandas】Merge函数

Merge函数是用于通过一个或多个键将两个数据集的行连接起来,类似于 SQL 中的 JOIN。主要使用场景是联表查询。

双表连接查询:

table1.merge(table2,on='index_x',now='left')

left处可以写right、inner、outer, 类似于SQL的左连接、右连接、内连接、外连接


多表:

pd.concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
          keys=None, levels=None, names=None, verify_integrity=False,
          copy=True)

objs: 用来进行连接查询的序列、dataframe或者panel对象。

axis: 轴(横轴纵轴)

join: inter取交集,outer取并集

...





猜你喜欢

转载自blog.csdn.net/kellyzxj/article/details/79966365