Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: support series.at[row_label] = scalar #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 7, 2023
Merged
12 changes: 12 additions & 0 deletions 12 bigframes/core/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ def __getitem__(
) -> Union[bigframes.core.scalar.Scalar, bigframes.series.Series]:
return self._series.loc[key]

def __setitem__(
self,
key: LocSingleKey,
value: bigframes.core.scalar.Scalar,
):
if not pd.api.types.is_scalar(value):
raise NotImplementedError(
"series.at.__setitem__ only supports scalar right-hand values. "
f"{constants.FEEDBACK_LINK}"
)
self._series.loc[key] = value


class LocDataFrameIndexer:
def __init__(self, dataframe: bigframes.dataframe.DataFrame):
Expand Down
11 changes: 11 additions & 0 deletions 11 tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,17 @@ def test_loc_setitem_cell(scalars_df_index, scalars_pandas_df_index):
pd.testing.assert_series_equal(bf_original.to_pandas(), pd_original)


def test_at_setitem_row_label_scalar(scalars_dfs):
scalars_df, scalars_pandas_df = scalars_dfs
bf_series = scalars_df["int64_col"]
pd_series = scalars_pandas_df["int64_col"].copy()
bf_series.at[1] = 1000
pd_series.at[1] = 1000
bf_result = bf_series.to_pandas()
pd_result = pd_series.astype("Int64")
pd.testing.assert_series_equal(bf_result, pd_result)


def test_ne_obj_series(scalars_dfs):
scalars_df, scalars_pandas_df = scalars_dfs
col_name = "string_col"
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.