bigframes.pandas.DataFrame.rename#
- DataFrame.rename(*, columns: Mapping[blocks.Label, blocks.Label]) DataFrame[source]#
- DataFrame.rename(*, columns: Mapping[blocks.Label, blocks.Label], inplace: Literal[False]) DataFrame
- DataFrame.rename(*, columns: Mapping[blocks.Label, blocks.Label], inplace: Literal[True]) None
Rename columns.
Dict values must be unique (1-to-1). Labels not contained in a dict will be left as-is. Extra labels listed don’t throw an error.
Examples:
>>> df = bpd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]}) >>> df A B 0 1 4 1 2 5 2 3 6 [3 rows x 2 columns]
Rename columns using a mapping:
>>> df.rename(columns={"A": "col1", "B": "col2"}) col1 col2 0 1 4 1 2 5 2 3 6 [3 rows x 2 columns]
- Parameters:
columns (Mapping) – Dict-like from old column labels to new column labels.
inplace (bool) – Default False. Whether to modify the DataFrame rather than creating a new one.
- Returns:
DataFrame with the renamed axis labels or None if
inplace=True.- Return type:
bigframes.pandas.DataFrame | None
- Raises:
KeyError – If any of the labels is not found.