Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
264becb
feat: limited support of lamdas in `Series.apply`
shobsi Jan 24, 2024
f98940b
Merge remote-tracking branch 'refs/remotes/github/main' into shobs-al…
shobsi Jan 25, 2024
266a3ea
add code sample for non-remote-function `Series.apply`
shobsi Jan 25, 2024
d3f9878
remove ..note in the middle of code samples due to rendering issue
shobsi Jan 25, 2024
af8651a
Merge remote-tracking branch 'refs/remotes/github/main' into shobs-al…
shobsi Jan 25, 2024
89b8dd1
fix typo
shobsi Jan 25, 2024
44b1689
Merge remote-tracking branch 'refs/remotes/github/main' into shobs-al…
shobsi Jan 25, 2024
4ed8f7b
add lambda test coverage and code samples for `Series.mask`
shobsi Jan 26, 2024
6b0dae7
Merge remote-tracking branch 'refs/remotes/github/main' into shobs-al…
shobsi Jan 31, 2024
2603ba1
apply the non-remote function on series level
shobsi Jan 31, 2024
1b93bc2
Merge remote-tracking branch 'refs/remotes/github/main' into shobs-al…
shobsi Feb 6, 2024
1e1551e
Merge remote-tracking branch 'refs/remotes/github/main' into shobs-al…
shobsi Feb 8, 2024
e782877
add suggestion to use remote function if direct func errors out
shobsi Feb 9, 2024
ac200ca
Merge remote-tracking branch 'refs/remotes/github/main' into shobs-al…
shobsi Feb 9, 2024
4357d4f
support by_row param in Series.apply
shobsi Feb 9, 2024
3b51709
raise ValueError instead of AssertionError
shobsi Feb 9, 2024
33d8b8b
fix Series.mask tests
shobsi Feb 10, 2024
6da45f0
Merge branch 'main' into shobs-allow-lambdas
shobsi Feb 12, 2024
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
Prev Previous commit
Next Next commit
raise ValueError instead of AssertionError
  • Loading branch information
shobsi committed Feb 9, 2024
commit 3b51709fc0ee4b3c8bd5a14721bfb3155b067e87
7 changes: 4 additions & 3 deletions bigframes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,10 @@ def apply(
# It is not a remote function
# Then it must be a vectorized function that applies to the Series
# as a whole
assert (
not by_row
), "A vectorized non-remote function can be provided only with by_row=False"
if by_row:
raise ValueError(
"A vectorized non-remote function can be provided only with by_row=False"
)

try:
return func(self)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it may result in incorrect values if this isn't a true vectorized function, let's check for by_row=False. If by_row="compat" (default) then raise and suggest either remote_function or by_row=False.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, PTAL.

Expand Down
6 changes: 3 additions & 3 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,7 @@ def test_apply_lambda(scalars_dfs, col, lambda_):
bf_col = scalars_df[col]

# Can't be applied to BigFrames Series without by_row=False
with pytest.raises(AssertionError, match="by_row=False"):
with pytest.raises(ValueError, match="by_row=False"):
bf_col.apply(lambda_)

bf_result = bf_col.apply(lambda_, by_row=False).to_pandas()
Expand Down Expand Up @@ -3142,7 +3142,7 @@ def test_apply_numpy_ufunc(scalars_dfs, ufunc):
bf_col = scalars_df["int64_col"]

# Can't be applied to BigFrames Series without by_row=False
with pytest.raises(AssertionError, match="by_row=False"):
with pytest.raises(ValueError, match="by_row=False"):
bf_col.apply(ufunc)

bf_result = bf_col.apply(ufunc, by_row=False).to_pandas()
Expand All @@ -3162,7 +3162,7 @@ def foo(x):
bf_col = scalars_df["int64_col"]

# Can't be applied to BigFrames Series without by_row=False
with pytest.raises(AssertionError, match="by_row=False"):
with pytest.raises(ValueError, match="by_row=False"):
bf_col.apply(foo)

bf_result = bf_col.apply(foo, by_row=False).to_pandas()
Expand Down