美文网首页
combine_first() 用法

combine_first() 用法

作者: 早点睡了 | 来源:发表于2021-08-02 11:45 被阅读0次

    Another fairly common situation is to have two like-indexed (or similarly indexed) Series or DataFrame objects and wanting to “patch” values in one object from values for matching indices in the other. Here is an example:

    In [133]: result = df1.combine_first(df2)
    

    可见,combine_first() 方法能够实现数两张表的填充,实际使用中非常方便。

    Note that this method only takes values from the right DataFrame if they are missing in the left DataFrame. A related method, update(), alters non-NA values in place:

    In [134]: df1.update(df2)
    

    相关文章

      网友评论

          本文标题:combine_first() 用法

          本文链接:https://www.haomeiwen.com/subject/islcvltx.html