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
Next Next commit
feat: limited support of lamdas in Series.apply
  • Loading branch information
shobsi committed Jan 24, 2024
commit 264becbd49eb9d6854768be492454f72fd7fb064
4 changes: 0 additions & 4 deletions bigframes/core/compile/scalar_op_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,6 @@ def isin_op_impl(x: ibis_types.Value, op: ops.IsInOp):

@scalar_op_compiler.register_unary_op(ops.RemoteFunctionOp, pass_op=True)
def remote_function_op_impl(x: ibis_types.Value, op: ops.RemoteFunctionOp):
if not hasattr(op.func, "bigframes_remote_function"):
Comment thread
shobsi marked this conversation as resolved.
raise TypeError(
f"only a bigframes remote function is supported as a callable. {constants.FEEDBACK_LINK}"
)
x_transformed = op.func(x)
if not op.apply_on_null:
x_transformed = ibis.case().when(x.isnull(), x).else_(x_transformed).end()
Expand Down
29 changes: 29 additions & 0 deletions tests/system/small/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2997,3 +2997,32 @@ def test_series_iter(
scalars_df_index["int64_too"], scalars_pandas_df_index["int64_too"]
):
assert bf_i == pd_i


@pytest.mark.parametrize(
("lambda_",),
[
pytest.param(lambda x: x * x + x + 1),
pytest.param(
lambda x: f"I got {x}",
marks=pytest.mark.xfail(
raises=AttributeError,
),
),
],
ids=[
"lamda_arithmatic",
"lambda_arbitrary",
],
)
def test_apply_lambda(scalars_dfs, lambda_):
scalars_df, scalars_pandas_df = scalars_dfs

bf_col = scalars_df["int64_col"]
bf_result = bf_col.apply(lambda_).to_pandas()

pd_col = scalars_pandas_df["int64_col"]
pd_result = pd_col.apply(lambda_)

# ignore dtype check, which are Int64 and object respectively
assert_series_equal(bf_result, pd_result, check_dtype=False)