❓Question: What are the categories of join? Give example for each.

 joins are operations used to combine rows from two or more data tables based on a related column, typically a key attribute.

  • Inner Join: Returns rows with matching keys in both tables.
    Example: Students enrolled in both Math and Physics.

  • Left Join: Returns all rows from the left table and matched rows from the right.
    Example: All students with their Physics marks (if available).

  • Right Join: Returns all rows from the right table and matched rows from the left.
    Example: All Physics marks with student names (if available).

  • Full Outer Join: Returns all rows when there is a match in either table.
    Example: All students and all marks, even if unmatched.

  • Cross Join: Returns Cartesian product of both tables.
    Example: Every student paired with every subject.

Python Example:

import pandas as pd
df1 = pd.DataFrame({'ID': [1,2], 'Name': ['A','B']})
df2 = pd.DataFrame({'ID': [1,3], 'Marks': [90, 85]})
print(pd.merge(df1, df2, on='ID', how='inner'))

Output:
Only ID=1 is matched → returns Name=A, Marks=90.