DataFrame.
import pandas dict1 = {"Subjects": ["Physics", "Chemistry", "Mathematics"], "Grades": ["A", "C", "B"], "Marks": [95, 72, 88]} df1 = pandas.DataFrame(dict1) print("df1: \n", df1) dict2 = {"Subjects": ["Biology", "Chemistry", "Literature"], "Marks": [85, 72, 68], "Remarks": ["Very Good", "Good", "Fair"]} df2 = pandas.DataFrame(dict2) print("df2: \n", df2) df6 = pandas.merge(df1, df2, how="outer", on="Subjects") print("After outer join: \n", df6)
As we can see the how parameter indicates we are performing one outer join operation. And the “on” parameter indicates that we are performing the merge operation on the “Subjects” column.
So, the output of the merge operation using outer join will be:
df1: Subjects Grades Marks 0 Physics A 95 1 Chemistry C 72 2 Mathematics B 88 df2: Subjects Marks Remarks 0 Biology 85 Very Good 1 Chemistry 72 Good 2 Literature 68 Fair After outer join: Subjects Grades Marks_x Marks_y Remarks 0 Physics A 95.0 NaN NaN 1 Chemistry C 72.0 72.0 Good 2 Mathematics B 88.0 NaN NaN 3 Biology NaN NaN 85.0 Very Good 4 Literature NaN NaN 68.0 Fair






0 Comments