Implicit Renaming

By implicit we mean that we do not explicitly specify the renaming operations, i.e. the columns to be named and the new column names to use. Rather, we specify criteria for selecting the columns to be renamed, and we provide a function that acts on the current names to return the new column names.

In its simplest form, a typical implicit data aggregation expression looks like so:

df_2 = df.rename(columns=str.lower)

We pass to rename() a function to apply to each column name (individually). The output is then used as the new column name.

This section is organized to cover the aspects of Implicit Renaming as follows:

  1. Function Specification where we cover how to specify the functions to be applied to the current column names to generate the desired names.
  2. Column Selection where we cover how to select the column(s) to be renamed when we only wish to rename a subset of columns.

Usually, the functions we provide for column renaming carry out some string manipulations e.g. replacing some characters, which we cover in String Operations.

PYTHON
I/O