Skip to main contentSkip to solution

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question