Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
Merged
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
add code sample for non-remote-function Series.apply
  • Loading branch information
shobsi committed Jan 25, 2024
commit 266a3ea2e4f6e25e04032e896c773d0860666e98
36 changes: 36 additions & 0 deletions third_party/bigframes_vendored/pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,42 @@ def apply(
>>> names = bpd.Series(["Alice", "Bob"])
>>> hashes = names.apply(get_hash)

There is a limited support of simple functions and lambdas which can be
operated directly (without converting into a `remote_function`) on the
BigQuery DataFrames objects.

.. note::
Bigframes does not yet support ``dict`` subclasses that define
``__missing__`` (i.e. provide a method for default values). These
are treated the same as ``dict``.

This approach takes advantage of a nuance in the way BigQuery DataFrames
objects are modelled internally and works only if the function body
contains only arithmatic or logical operators.

>>> nums = bpd.Series([1, 2, 3, 4])
>>> nums
0 1
1 2
2 3
3 4
dtype: Int64
>>> nums.apply(lambda x: x*x + 2*x + 1)
0 4
1 9
2 16
3 25
dtype: Int64

>>> def is_odd(num):
... return num % 2 == 1
>>> nums.apply(is_odd)
0 True
1 False
2 True
3 False
dtype: boolean

Args:
func (function):
BigFrames DataFrames ``remote_function`` to apply. The function
Expand Down