Skip to content
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

feat: Allow DataFrame binary ops to align on either axis and with loc… #544

Merged
merged 10 commits into from
Apr 4, 2024

Conversation

TrevorBergeron
Copy link
Contributor

…al objects.

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 #<issue_number_goes_here> 🦕

@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 Mar 29, 2024
@TrevorBergeron TrevorBergeron marked this pull request as ready for review April 1, 2024 19:23
@TrevorBergeron TrevorBergeron requested review from a team as code owners April 1, 2024 19:23
@TrevorBergeron TrevorBergeron requested review from milkshakeiii and removed request for Genesis929 April 1, 2024 23:08
"bf_series",
],
)
def test_listlike_binop_axis_1(scalars_dfs, input):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add axis=1 to some existing tests for various binary ops?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

axis=1 completely changes alignment so the objects would just fail to align on this axis for existing tests. I'm not too worried about the different ops breaking, the actual scalar op compilation doesn't change for axis=1, the big worry is alignment failing

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right, the existing objects wouldn't wouldn't work. Okay, sounds good.

import bigframes.series as series


def normalize_to_bf_series(obj, default_index: index.Index) -> series.Series:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer just "to_bf_series" since to_blah seems like a common name for things that basically just convert, and "normalize" has so many possible meanings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

elif isinstance(other, DataFrame):
return self._apply_dataframe_binop(other, op, how=how, reverse=reverse)
elif isinstance(other, pandas.DataFrame):
Copy link
Contributor

Choose a reason for hiding this comment

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

might need to add pandas.DataFrame to the type hint for other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For what purpose? Mypy is able to infer based on the isinstance checks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, gotcha, but should we remove the other type hints then? Just for consistency/cleanliness.

@TrevorBergeron TrevorBergeron merged commit 6d8f3af into main Apr 4, 2024
16 checks passed
@TrevorBergeron TrevorBergeron deleted the index_align branch April 4, 2024 16:12
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.

2 participants