🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: groupby and merge: all 10 questions

Quiz: groupby and merge · Question 6 of 10

What does this print? (code)

What does this print?

import pandas as pd
students = pd.DataFrame({"roll": [1, 2, 3], "name": ["Asha", "Ravi", "Neha"]})
offers = pd.DataFrame({"roll": [1, 1, 3], "company": ["TCS", "Zoho", "Wipro"]})
print(len(students.merge(offers, on="roll", how="inner")), len(students.merge(offers, on="roll", how="left")))
  1. A.3 3
  2. B.2 3
  3. C.3 4
  4. D.2 4
Answer & explanation

Correct answer: 3 4

Asha's two offers give two rows; the left join also keeps Ravi with no offer.

Can you get the rest right without peeking?

Take the timed Quiz: groupby and merge quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →