Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

feat: Add DataFrame.corrwith method#1315

Merged
TrevorBergeron merged 3 commits intomainfrom
corr_with
Jan 24, 2025
Merged

feat: Add DataFrame.corrwith method#1315
TrevorBergeron merged 3 commits intomainfrom
corr_with

Conversation

@TrevorBergeron
Copy link
Copy Markdown
Contributor

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 Jan 23, 2025
@TrevorBergeron TrevorBergeron marked this pull request as ready for review January 23, 2025 18:54
@TrevorBergeron TrevorBergeron requested review from a team and tswast January 23, 2025 18:54
@TrevorBergeron TrevorBergeron requested review from sycai and removed request for tswast January 23, 2025 22:33
Comment thread bigframes/dataframe.py Outdated
numeric_only: bool = False,
):
other_frame = other if isinstance(other, DataFrame) else other.to_frame()
if not numeric_only:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's re-write this if-else block as

if numeric_only:
...
else
...

See go/tott/685

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

pd.testing.assert_series_equal(
bf_result, pd_result, check_dtype=False, check_index_type=False
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps we should add two more cases:

numeric_only = True, two dfs contain only numeric columns => computation proceeds successfully
numeric_only = True, one of the dfs has a non-numeric column => an error is raised.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added

@TrevorBergeron TrevorBergeron requested a review from sycai January 24, 2025 00:35
@TrevorBergeron TrevorBergeron merged commit b503355 into main Jan 24, 2025
@TrevorBergeron TrevorBergeron deleted the corr_with branch January 24, 2025 01:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

3 participants