rename()

noun

say it: “ree-NAYM” /riˈneɪm/

A pandas method that gives a table's columns new names.

What does rename() do in pandas?

rename() is the pandas method that hands back a table with new column names. columns= takes a dictionary of old name to new name; columns it doesn't name keep theirs. A report uses it to turn names such as class_name into words people read.

table = by_class.rename(columns={"class_name": "Class", "fee": "Fee", "fill": "Seats filled"})

In a sentence

  • “rename() turned class_name into Class for the report.”
  • “He used rename() so the table's headings read as plain words.”

Level: Journeyman · More Python terms at this level

Updated