Question:

While appending two dataframes, if we want to raise error in case row labels are duplicate, we shall use which parameter of append() method?

Show Hint

The parameter verify_integrity=True checks the new index for duplicates and raises ValueError.
Updated On: Oct 1, 2026
  • ignore_index = False
  • row_index = False
  • in_place = True
  • verify_integrity = True
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Understanding the Concept:
When two DataFrames are joined with append(), their row labels (the index values) are copied into the result. The same label can then appear twice. Pandas has a parameter to check for this.

Step 2: Recall the parameter.
The parameter verify_integrity is a Boolean. When it is True, pandas checks the new index for duplicates. If it finds any, it raises a ValueError. The default is False, so no check is done. I checked this in Python with pd.concat([d1, d2], verify_integrity=True) and got a ValueError for duplicate labels.

Step 3: Check option 1 (ignore_index = False).
ignore_index is a real parameter. When it is True, old labels are dropped and new labels 0, 1, 2 and so on are given. Setting it to False keeps the old labels and does not raise any error. So option 1 is wrong.

Step 4: Check option 2 (row_index = False).
There is no parameter named row_index in append(). So option 2 is wrong.

Step 5: Check option 3 (in_place = True).
append() has no in_place parameter. It always returns a new DataFrame. So option 3 is wrong.

Step 6: Check option 4 (verify_integrity = True).
This is the correct parameter. It raises an error when duplicate row labels are found. So option 4 is correct.

Step 7: Final Answer:
The parameter is verify_integrity = True, which is option 4. \[ \boxed{\text{verify\_integrity = True}} \]
Was this answer helpful?
0
0