Skip to content

feat: Support args in series apply method #2013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jialuoo
Copy link
Contributor

@jialuoo jialuoo commented Aug 21, 2025

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes b/440342212.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Aug 21, 2025
@jialuoo jialuoo marked this pull request as ready for review August 21, 2025 17:19
@jialuoo jialuoo requested review from a team as code owners August 21, 2025 17:19
func,
by_row: typing.Union[typing.Literal["compat"], bool] = "compat",
*,
args: typing.Tuple = (),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In pandas args can be a positional argument while by_row is a keyword only argument https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.apply.html#pandas-series-apply. I would argue that we can adhere to that right now as I don't anticipate many people passing by_row positional argument, but if not, we should add an item in BigFrames 3.0 to make the breaking change.

bf_result_col = scalars_df["int64_too"].apply(
foo_list, args=(12.34, b"hello world", False)
)
bf_result = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why we need to convert to put it in a DataFrame before asserting. Can't we compare bf_result_col and pd_result_col directly?

)

# Ignore any dtype difference.
pandas.testing.assert_frame_equal(bf_result, pd_result, check_dtype=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other comment, why not assert_series_equal on the result of the apply?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants