pandas

In pandas, you can use the following command: 

    pd.merge(df1,df2,on='key',how='left')

The following is the output to the preceding commands:

Output of the left join between the two tables

As expected of a left join, it retrieves all the unique values of the key present in the left-hand table (df1, in this case), as well as the corresponding values in the right-hand table. For the key values in the left-hand table for which it doesn't find a match in the right-hand table, it returns NaN.

Suppose we want to implement a right join between the two. This can be done in the two tools as shown here:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset