diff --git a/bigframes/series.py b/bigframes/series.py index f9aa59d6ec..e7b358c2fe 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -109,6 +109,11 @@ def at(self) -> bigframes.core.indexers.AtSeriesIndexer: def name(self) -> blocks.Label: return self._name + @name.setter + def name(self, label: blocks.Label): + new_block = self._block.with_column_labels([label]) + self._set_block(new_block) + @property def shape(self) -> typing.Tuple[int]: return (self._block.shape[0],) diff --git a/tests/system/small/test_series.py b/tests/system/small/test_series.py index e35d2f3377..010ad323e7 100644 --- a/tests/system/small/test_series.py +++ b/tests/system/small/test_series.py @@ -1667,6 +1667,21 @@ def test_empty_true_memtable(session: bigframes.Session): assert bf_result == pd_result +def test_series_names(scalars_dfs): + scalars_df, scalars_pandas_df = scalars_dfs + + bf_result = scalars_df["string_col"].copy() + bf_result.index.name = "new index name" + bf_result.name = "new series name" + + pd_result = scalars_pandas_df["string_col"].copy() + pd_result.index.name = "new index name" + pd_result.name = "new series name" + + assert pd_result.name == bf_result.name + assert pd_result.index.name == bf_result.index.name + + def test_dtype(scalars_dfs): scalars_df, scalars_pandas_df = scalars_dfs