熊猫merge()–合并两个DataFrame对象

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值