rename_columns

The rename_columns method creates a new table with specified columns renamed.

Syntax

Parameters

ParameterTypeDescription
colsUnion[str, Sequence[str]]

Columns that will be renamed in the new table.

  • "X = Y" will rename source column Y to X.

Important

If the new column name conflicts with an existing column name in the table, the existing column will be silently replaced.

Returns

A new table that renames the specified columns.

Examples

The following example renames columns A and C:

The following example renames column C to A. Because A already exists, it is silently replaced with the renamed C column: