Skip to content

Commit 1a658b2

Browse files
authored
feat: improve error message in Series.apply for direct udfs (#1673)
* feat: improve error message in `Series.apply` for direct udfs * remove stray file, improve message * specify namespace for udf and remote_function in the error message * fix typo
1 parent 48992e2 commit 1a658b2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

bigframes/series.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,9 +1712,18 @@ def apply(
17121712
# as a whole.
17131713
if by_row:
17141714
raise ValueError(
1715-
"A vectorized non-BigFrames BigQuery function can be "
1716-
"provided only with by_row=False. For element-wise operation "
1717-
"it must be a BigFrames BigQuery function."
1715+
"You have passed a function as-is. If your intention is to "
1716+
"apply this function in a vectorized way (i.e. to the "
1717+
"entire Series as a whole, and you are sure that it "
1718+
"performs only the operations that are implemented for a "
1719+
"Series (e.g. a chain of arithmetic/logical operations, "
1720+
"such as `def foo(s): return s % 2 == 1`), please also "
1721+
"specify `by_row=False`. If your function contains "
1722+
"arbitrary code, it can only be applied to every element "
1723+
"in the Series individually, in which case you must "
1724+
"convert it to a BigFrames BigQuery function using "
1725+
"`bigframes.pandas.udf`, "
1726+
"or `bigframes.pandas.remote_function` before passing."
17181727
)
17191728

17201729
try:

0 commit comments

Comments
 (0)