Rename columns according either a dictionary or kwargs. If a mapping is provided using a dictionary, ``rename_by_dict`` will be used. Otherwise, ``rename_columns`` will be used with kwargs. Columns not in keys(kwargs) are not changed. New name of a column must not be ``id``.
(
self,
names_mapping: dict[str | expr.ColumnReference, str] | None = None,
**kwargs: expr.ColumnExpression,
)
| 2145 | @trace_user_frame |
| 2146 | @check_arg_types |
| 2147 | def rename( |
| 2148 | self, |
| 2149 | names_mapping: dict[str | expr.ColumnReference, str] | None = None, |
| 2150 | **kwargs: expr.ColumnExpression, |
| 2151 | ) -> Table: |
| 2152 | """Rename columns according either a dictionary or kwargs. |
| 2153 | |
| 2154 | If a mapping is provided using a dictionary, ``rename_by_dict`` will be used. |
| 2155 | Otherwise, ``rename_columns`` will be used with kwargs. |
| 2156 | Columns not in keys(kwargs) are not changed. New name of a column must not be ``id``. |
| 2157 | |
| 2158 | Args: |
| 2159 | names_mapping: mapping from old column names to new names. |
| 2160 | kwargs: mapping from old column names to new names. |
| 2161 | |
| 2162 | Returns: |
| 2163 | Table: `self` with columns renamed. |
| 2164 | """ |
| 2165 | if names_mapping is not None: |
| 2166 | return self.rename_by_dict(names_mapping=names_mapping) |
| 2167 | return self.rename_columns(**kwargs) |
| 2168 | |
| 2169 | @trace_user_frame |
| 2170 | @desugar |