

Use the column parameter of DataFrame.rename() function and pass the columns to be renamed. Sometimes it is required to rename the single or specific column names only. Also, It raises KeyError If any of the labels are not found in the selected axis when errors='raise'.It returns a DataFrame with the renamed column and row labels or None if inplace=True.If ‘ignore’, existing keys will be renamed and extra keys will be ignored. If ‘raise’, raise a KeyError if the columns or index are not present. errors: It is either ‘ignore’ or ‘raise’.level: In the case of a multi-index DataFrame, only rename labels in the specified level.
#Dataframe rename column update

It takes to dictionary or function as input. columns: It is used to specify new names for columns.It takes a Python dictionary or function as input. mapper: It is used to specify new names for columns.Syntax: DataFrame.rename(mapper=None, columns=None, axis=None, copy=True, inplace=False, level=None, errors='ignore') Let’s see the syntax of it before moving to examples. This is the most widely used pandas function for renaming columns and row indexes. Rename columns by removing leading and trailing spaces.Using rename with axis=’columns’ or axis=1.
