Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 2 : Only rows whose 'id' exists in both DataFrames / केवल वे पंक्तियाँ जिनका 'id' दोनों DataFrame में हो

Advertisement

Detailed Solution

सही उत्तर Only rows whose 'id' exists in both DataFrames / केवल वे पंक्तियाँ जिनका 'id' दोनों DataFrame में हो है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

In pd.merge(df1, df2, on='id', how='inner'), which rows appear in the result? / pd.merge(df1, df2, on='id', how='inner') में परिणाम में कौन-सी पंक्तियाँ आती हैं?

1.
All rows of df1, with NaN where df2 has no match / df1 की सभी पंक्तियाँ, जहाँ df2 में मेल न हो वहाँ NaN
2.
Only rows whose 'id' exists in both DataFrames / केवल वे पंक्तियाँ जिनका 'id' दोनों DataFrame में हो
3.
All rows of both DataFrames / दोनों DataFrame की सभी पंक्तियाँ
4.
Only rows whose 'id' is missing from df2 / केवल वे पंक्तियाँ जिनका 'id' df2 में न हो

Correct Answer: Only rows whose 'id' exists in both DataFrames / केवल वे पंक्तियाँ जिनका 'id' दोनों DataFrame में हो

An inner merge keeps only the key values present in both DataFrames. Keeping all left rows with NaN fill is a left merge, not an inner merge. / इनर मर्ज केवल वे कुंजी-मान रखता है जो दोनों DataFrame में हों। बायीं सभी पंक्तियाँ NaN के साथ रखना लेफ्ट मर्ज है, इनर नहीं।

Downloaded from PrepSnap (prepsnap.in)