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
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
docs: add code samples for read_gbq_function using community UDFs
  • Loading branch information
ashleyxuu committed Nov 8, 2023
commit 2e82b89c9ec54e6b136f1ab43d8c135e2ac850ed
30 changes: 26 additions & 4 deletions bigframes/session/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,15 +1456,37 @@ def read_gbq_function(
The return type of the function must be explicitly specified in the
function's original definition even if not otherwise required.

BigQuery UDFs has many public functions under the ``bqutil`` project on publicly shared datasets
Comment thread
ashleyxuu marked this conversation as resolved.
Outdated
(See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs#using-the-udfs).
You can checkout Community UDFs to use community-contributed functions.
(See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs/community#community-udfs).

**Examples:**

Using the ``cw_lower_case_ascii_only`` function from Community UDFs.
Comment thread
ashleyxuu marked this conversation as resolved.
Outdated
(https://github.com/GoogleCloudPlatform/bigquery-utils/blob/master/udfs/community/cw_lower_case_ascii_only.sqlx)

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

>>> function_name = "bqutil.fn.cw_lower_case_ascii_only"
>>> func = bpd.read_gbq_function(function_name=function_name)
>>> func.bigframes_remote_function
'bqutil.fn.cw_lower_case_ascii_only'
>>> df = bpd.DataFrame({'id': [1, 2, 3], 'name': ['AURÉLIE', 'CÉLESTINE', 'DAPHNÉ']})
>>> df
id name
0 1 AURÉLIE
1 2 CÉLESTINE
2 3 DAPHNÉ
<BLANKLINE>
[3 rows x 2 columns]

>>> func = bpd.read_gbq_function("bqutil.fn.cw_lower_case_ascii_only")
>>> df1 = df.assign(new_name=df['name'].apply(func))
>>> df1
id name new_name
0 1 AURÉLIE aurÉlie
1 2 CÉLESTINE cÉlestine
2 3 DAPHNÉ daphnÉ
<BLANKLINE>
[3 rows x 3 columns]

Args:
function_name (str):
Expand Down