janitor.rename_columns

janitor.rename_columns(df: pandas.core.frame.DataFrame, new_column_names: Dict) → pandas.core.frame.DataFrame[source]

Rename columns in place.

Functional usage syntax:

df = rename_columns(df, {"old_column_name": "new_column_name"})

Method chaining syntax:

import pandas as pd
import janitor
df = pd.DataFrame(...).rename_columns({"old_column_name": "new_column_name"})

This is just syntactic sugar/a convenience function for renaming one column at a time. If you are convinced that there are multiple columns in need of changing, then use the pandas.DataFrame.rename() method.

Parameters
  • df – The pandas DataFrame object.

  • new_column_names – A dictionary of old and new column names.

Returns

A pandas DataFrame with renamed columns.