Skip to content

TYP : DataFrame.(merge, join) core.reshape.merge.(merge, ...) (easy) #38468

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 10 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
29 changes: 18 additions & 11 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
FormattersType,
FrameOrSeriesUnion,
IndexKeyFunc,
IndexLabel,
Label,
Level,
Renamer,
Expand Down Expand Up @@ -8157,7 +8158,13 @@ def join(
)

def _join_compat(
self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False
self,
other,
on: Optional[IndexLabel] = None,
how: str = "left",
lsuffix: str = "",
rsuffix: str = "",
sort: bool = False,
):
from pandas.core.reshape.concat import concat
from pandas.core.reshape.merge import merge
Expand Down Expand Up @@ -8222,18 +8229,18 @@ def _join_compat(
@Appender(_merge_doc, indents=2)
def merge(
self,
right,
how="inner",
on=None,
right: FrameOrSeriesUnion,
how: str = "inner",
on: Optional[IndexLabel] = None,
left_on=None,
right_on=None,
left_index=False,
right_index=False,
sort=False,
suffixes=("_x", "_y"),
copy=True,
indicator=False,
validate=None,
left_index: bool = False,
right_index: bool = False,
sort: bool = False,
suffixes: Tuple[str, str] = ("_x", "_y"),
Copy link
Member

Choose a reason for hiding this comment

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

FYI. suffixes can currently be list-like but will change in the future. but I think OK to restrict to tuple here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it worth creating a Suffix alias? (So there's a single place where the behavior can be changed?) I would also change this to List if doing that

Copy link
Member

Choose a reason for hiding this comment

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

yes, probably worth creating an alias as used in several places.

I don't think we need to include Sequence though (situation maybe different if types were public/not experimental or we were using a stub that had support for multiple pandas versions).

copy: bool = True,
indicator: bool = False,
validate: Optional[str] = None,
) -> DataFrame:
from pandas.core.reshape.merge import merge

Expand Down
20 changes: 10 additions & 10 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np

from pandas._libs import Timedelta, hashtable as libhashtable, join as libjoin, lib
from pandas._typing import ArrayLike, FrameOrSeries, FrameOrSeriesUnion
from pandas._typing import ArrayLike, FrameOrSeries, FrameOrSeriesUnion, IndexLabel
from pandas.errors import MergeError
from pandas.util._decorators import Appender, Substitution

Expand Down Expand Up @@ -57,19 +57,19 @@
@Substitution("\nleft : DataFrame")
@Appender(_merge_doc, indents=0)
def merge(
left,
right,
left: FrameOrSeriesUnion,
right: FrameOrSeriesUnion,
how: str = "inner",
on=None,
on: Optional[IndexLabel] = None,
left_on=None,
right_on=None,
left_index: bool = False,
right_index: bool = False,
sort: bool = False,
suffixes=("_x", "_y"),
suffixes: Tuple[str, str] = ("_x", "_y"),
copy: bool = True,
indicator: bool = False,
validate=None,
validate: Optional[str] = None,
) -> "DataFrame":
op = _MergeOperation(
left,
Expand Down Expand Up @@ -583,17 +583,17 @@ def __init__(
left: FrameOrSeriesUnion,
right: FrameOrSeriesUnion,
how: str = "inner",
on=None,
on: Optional[IndexLabel] = None,
left_on=None,
right_on=None,
axis=1,
axis: int = 1,
left_index: bool = False,
right_index: bool = False,
sort: bool = True,
suffixes=("_x", "_y"),
suffixes: Tuple[str, str] = ("_x", "_y"),
copy: bool = True,
indicator: bool = False,
validate=None,
validate: Optional[str] = None,
):
_left = _validate_operand(left)
_right = _validate_operand(right)
Expand Down