Skip to content

fix: Series iteration correctly returns values instead of index #339

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 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Series iteration correctly returns values instead of index
  • Loading branch information
TrevorBergeron committed Jan 23, 2024
commit a473140473eff4de91c9124b3f52a005db0f1097
2 changes: 1 addition & 1 deletion bigframes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __len__(self):

def __iter__(self) -> typing.Iterator:
return itertools.chain.from_iterable(
map(lambda x: x.index, self._block.to_pandas_batches())
map(lambda x: x.squeeze(axis=1), self._block.to_pandas_batches())
)

def copy(self) -> Series:
Expand Down
10 changes: 10 additions & 0 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2987,3 +2987,13 @@ def test_sample(scalars_dfs, frac, n, random_state):
n = 1 if n is None else n
expected_sample_size = round(frac * scalars_df.shape[0]) if frac is not None else n
assert bf_result.shape[0] == expected_sample_size


def test_series_iter(
scalars_df_index,
scalars_pandas_df_index,
):
for bf_i, pd_i in zip(
scalars_df_index["int64_too"], scalars_pandas_df_index["int64_too"]
):
assert bf_i == pd_i