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

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鈥檒l 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 all commits
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
2 changes: 1 addition & 1 deletion 2 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 10 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
12 changes: 6 additions & 6 deletions 12 third_party/bigframes_vendored/pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def size(self) -> int:

def __iter__(self) -> Iterator:
"""
Iterate over info axis.
Iterate over column axis for DataFrame, or values for Series.

Returns
iterator: Info axis as iterator.
Returns:
iterator

**Examples:**
>>> import bigframes.pandas as bpd
Expand All @@ -71,9 +71,9 @@ def __iter__(self) -> Iterator:
>>> series = bpd.Series(["a", "b", "c"], index=[10, 20, 30])
>>> for x in series:
... print(x)
10
20
30
a
b
c
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.