Skip to content

Commit 7506eab

Browse files
authored
docs: add code samples for read_gbq_function using community UDFs (#188)
* docs: add code samples for read_gbq_function using community UDFs
1 parent 87f84c9 commit 7506eab

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

bigframes/session/__init__.py

+26-4
Original file line numberDiff line numberDiff line change
@@ -1322,15 +1322,37 @@ def read_gbq_function(
13221322
The return type of the function must be explicitly specified in the
13231323
function's original definition even if not otherwise required.
13241324
1325+
BigQuery Utils provides many public functions under the ``bqutil`` project on Google Cloud Platform project
1326+
(See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs#using-the-udfs).
1327+
You can checkout Community UDFs to use community-contributed functions.
1328+
(See: https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/udfs/community#community-udfs).
1329+
13251330
**Examples:**
13261331
1332+
Use the ``cw_lower_case_ascii_only`` function from Community UDFs.
1333+
(https://github.com/GoogleCloudPlatform/bigquery-utils/blob/master/udfs/community/cw_lower_case_ascii_only.sqlx)
1334+
13271335
>>> import bigframes.pandas as bpd
13281336
>>> bpd.options.display.progress_bar = None
13291337
1330-
>>> function_name = "bqutil.fn.cw_lower_case_ascii_only"
1331-
>>> func = bpd.read_gbq_function(function_name=function_name)
1332-
>>> func.bigframes_remote_function
1333-
'bqutil.fn.cw_lower_case_ascii_only'
1338+
>>> df = bpd.DataFrame({'id': [1, 2, 3], 'name': ['AURÉLIE', 'CÉLESTINE', 'DAPHNÉ']})
1339+
>>> df
1340+
id name
1341+
0 1 AURÉLIE
1342+
1 2 CÉLESTINE
1343+
2 3 DAPHNÉ
1344+
<BLANKLINE>
1345+
[3 rows x 2 columns]
1346+
1347+
>>> func = bpd.read_gbq_function("bqutil.fn.cw_lower_case_ascii_only")
1348+
>>> df1 = df.assign(new_name=df['name'].apply(func))
1349+
>>> df1
1350+
id name new_name
1351+
0 1 AURÉLIE aurÉlie
1352+
1 2 CÉLESTINE cÉlestine
1353+
2 3 DAPHNÉ daphnÉ
1354+
<BLANKLINE>
1355+
[3 rows x 3 columns]
13341356
13351357
Args:
13361358
function_name (str):

0 commit comments

Comments
 (0)