![]() ![]() |
Pandas (page 8 of 9) |
We can join or combine DataFrames by executing something like one of the following:
1. pd.concat([df1, df2], axis=1) — add the columns in df1 to the end of df2 (rows should be identical)
2. df1.join(df2, on=col1, how='inner') — SQL-style join whereby the columns in df1 and the columns on df2 are combined where the rows for col1 have matching values across the two data frames. The how (join type) can be equal to one of 'left', 'right', 'outer', or 'inner' depending on how the data need to be merged.