Merge two Pandas Dataframes

    0

    0

    Javier Pacheco

    This code creates a new table called "merged" that is a union of the two original tables. The first argument is the name of the table to be created, the second is the name of the table to be merged into it, and the third is the default merge method (which is "inner"). The fourth argument is a boolean that tells the merge function which table should be the "left" table and which should be the "right" table. The fifth argument is a string that tells the merge function which column to use as the "left" column and which column to use as the "right" column.

    import pandas as pd
    
    MERGED = pd.merge(
      table1, table2, how="how", left_on="id_table1", right_on="id_table2"
    )
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.