Pandas DataFrame merge() function is used to merge two DataFrame objects with a database-style join operation. The joining is performed on columns or indexes.
Pandas DataFrame merge()函数用于通过数据库样式的合并操作合并两个DataFrame对象。 连接是对列或索引执行的。
If the joining is done on columns, indexes are ignored. This function returns a new DataFrame and the source DataFrame objects are unchanged.
如果对列进行了连接,则索引将被忽略。 此函数返回一个新的DataFrame,并且源DataFrame对象不变。
Pandas DataFrame merge()函数语法 (Pandas DataFrame merge() Function Syntax)
The merge() function syntax is:
merge()函数的语法为:
def merge(
self,
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,
)
- right: The other DataFrame to merge with the source DataFrame. right :另一个与源DataFrame合并的DataFrame。
- how: {‘left’, ‘right’, ‘outer’, ‘inner’}, default ‘inner’. This is the most important parameter to define the merge operation type. These are similar to SQL left outer join, right outer join, full outer join, and inner join. 方式 :{'左','右','外','内'},默认为'内'。 这是定义合并操作类型的最重要参数。 这些类似于SQL的左外部联接,右外部联接,完全外部联接和内部联接。
- on: Column or index level names to join on. These columns must be present in both the DataFrames. If not provided, the intersection of the columns