Skip to content

Add dataframe.join #238

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

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions spec/API_specification/dataframe_api/dataframe_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,3 +897,35 @@ def to_array_object(self, dtype: Any) -> Any:
understanding that consuming libraries would then use the
``array-api-compat`` package to convert it to a Standard-compliant array.
"""

def join(
self,
other: DataFrame,
*,
how: Literal['left', 'inner', 'outer'],
left_on: str | list[str],
right_on: str | list[str],
) -> DataFrame:
"""
Join with other dataframe.

Parameters
----------
other : DataFrame
Dataframe to join with.
how : str
Kind of join to perform.
Must be one of {'left', 'inner', 'outer'}.
Comment on lines +916 to +918
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know right joins can be modeled as left joins with the inputs swapped, but any reason not to support right as a join type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know right joins can be modeled as left joins with the inputs swapped

exactly, so if the idea is to make a minimal API, right joins probably aren't needed. have never seem them in practice anyway

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can always add them later without it being a breaking change, so I'm good with not including them until there's clear feedback that they're needed / wanted.

left_on : str | list[str]
Key(s) from `self` to perform `join` on.
If more than one key is given, it must be
the same length as `right_on`.
right_on : str | list[str]
Key(s) from `other` to perform `join` on.
If more than one key is given, it must be
the same length as `left_on`.

Returns
-------
DataFrame
"""