w3resource

Pandas Advanced Merging and Joining: Exercises with Solutions and Explanation


This resource offers a total of 100 Pandas Advanced Merging and Joining problems for practice. It includes 20 main exercises, each accompanied by solutions, detailed explanations, and four related problems.

[An Editor is available at the bottom of the page to write and execute the scripts.]


1. Merge on Single Column

Write a Pandas program to merge two DataFrames on a single column.

Click me to see the sample solution


2. Outer Join Merge

Write a Pandas program to perform an outer join on two DataFrames.

Click me to see the sample solution


3. Left Join Merge

Write a Pandas program that performs a left join of two DataFrames.

Click me to see the sample solution


4. Right Join Merge

Write a Pandas program that performs a right join of two DataFrames.

Click me to see the sample solution


5. Merge on Multiple Columns

Write a Pandas program to merge two DataFrames on multiple columns.

Click me to see the sample solution


6. Merge Overlapping Columns

Write a Pandas program that merges DataFrames with overlapping column names.

Click me to see the sample solution


7. Merge on Index

Write a Pandas program to merge two DataFrames on their indexes.

Click me to see the sample solution


8. Merge Diff Column Names

Write a Pandas program to merge different column names in DataFrames.

Click me to see the sample solution


9. Merge Duplicate Keys

Write a Pandas program to merge DataFrames with duplicate Keys.

Click me to see the sample solution


10. Merge Multiple DataFrames

Write a Pandas program to merge multiple DataFrames on a common column.

Click me to see the sample solution


11. Join on Index

Write a Pandas program to merge DataFrames using join() on Index.

Click me to see the sample solution


12. Merge with Indicator

Write a Pandas program to merge with custom indicator to track source.

Click me to see the sample solution


13. Merge Multiple Keys with Conditions

Write a Pandas program to merge two DataFrames using multiple keys and specific join conditions.

Click me to see the sample solution


14. Merge with Suffixes

Write a Pandas program to merge DataFrames using suffixes for overlapping columns.

Click me to see the sample solution


15. Merge with Custom Sorting

Write a Pandas program to merge DataFrames with custom sorting.

Click me to see the sample solution


16. Merge and Drop Duplicates

Write a Pandas program to merge DataFrames and drop duplicates.

Click me to see the sample solution


17. Merge with Missing Data

Write a Pandas program to merge DataFrames with missing data.

Click me to see the sample solution


18. Merge and Rename Columns

Write a Pandas program to merge DataFrames and rename columns after merge.

Click me to see the sample solution


19. Merge Multi-Col Diff Names

Write a Pandas program to merge DataFrames on multiple columns with different names.

Click me to see the sample solution


20. Merge and Select Columns

Write a Pandas program that merges DataFrames and select specific columns after merge.

Click me to see the sample solution


Python-Pandas Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Test your Python skills with w3resource's quiz



Follow us on Facebook and Twitter for latest update.