Skip to main content
Questions Why Us Pricing Log In Sign Up

Modifying Structure: Renaming Columns

How do we rename columns in a DataFrame?

Answer

We use df.rename(). The key parameter is columns=, which can take either:

  1. a dictionary mapping old_name : new_name, or

  2. a string function applied to every column name.

Example:

Python
# Dict 
df.rename(columns = {"Calories" : "Cal"})

# Str Function
df.rename(columns = str.lower)
← Back to collection
← Previous question Inspection Next question Transformations: How to Do Them →

Social

  • Instagram

Contact

  • linkedin.com/in/rinorbirinxhiku/

Legal

  • Privacy Policy
  • Terms of Service
© 2026 quant.rb. All rights reserved.