DataFrame.
merge
(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)
功能:通过按列或索引执行数据库式连接操作来合并DataFrame对象。
如果连接列和列的话,索引将被忽略。否则,如果连接索引和索引或索引和列的话,索引将会被传递。
参数:right : DataFrame
how : {‘left’, ‘right’, ‘outer’, ‘inner’}, default ‘inner’
left:只使用左边框的键,类似于SQL左外部连接; 保持按键顺序
right:仅使用右框架中的键,类似于SQL右外连接; 保持按键顺序
outer:使用两个框架中的键的联合,类似于SQL全外连接; 按字典顺序排序键
inner:使用来自两个框架的键的交集,类似于SQL内部联接; 保留左键的顺序
on:标签或列表
用于连接的列名。必须存在于左右两个DatFrame对象中。如果未指定,且其他键也未指定,则以left和right列名的交集作为连接键。
left_on : label or list, or array-like
左侧DataFrame中用作连接键的列
right_on : label or list, or array-like
左侧DataFrame中用作连接键的列
left_index : boolean, default False
使用左侧DataFrame中的索引作为连接键。 如果它是一个MultiIndex,另一个DataFrame中的键的数量(索引或列数)必须匹配层数
right_index : boolean, default False
使用右侧DataFrame中的索引作为连接键。 与left_index相同的警告
sort : boolean, default False
在结果DataFrame中按字典顺序排列连接键。 如果为False,则连接键的顺序取决于连接类型(关键字如何)
suffixes : 2-length sequence (tuple, list, ...)
字符串值元组,用于追加到重叠列名的末尾,默认为('_x','_y')。李若,如果左右两个DataFrame对象都有"Data",则结果中就会出现“data_x”和“data_y”
copy : boolean, default True
如果为False,可以在某些特殊情况下避免将数据复制到结果数据结构中。默认总是复制。
indicator : boolean or string, default False
validate : string, default None