Identify the correct function to change the name of row label in a DataFrame.
Identify the correct function to change the name of row label in a DataFrame.
Solution
✅ Correct Option: 3
The pandas method rename() changes row labels (index) or column labels of a DataFrame. For row labels, pass a dictionary to the index parameter, for example df.rename(index={'a': 'x'}). The same method with columns= changes column names.
Options 1 and 2: pandas has no change() or modify() method for DataFrames.
Option 4: update() exists, but it modifies the values of a DataFrame using another DataFrame. It does not change labels.
Related questions:
2025: 27 May Shift 2
2025: 22 May Shift 1
2025: 14 May Shift 1
2026: 21 May Shift 1