Skip to content

Commit

Permalink
TYP and DOC: pd.merge accepts Series (pandas-dev#41594)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Irv authored and TLouf committed Jun 1, 2021
1 parent 034df31 commit dc1c978
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@
_merge_doc = """
Merge DataFrame or named Series objects with a database-style join.
A named Series object is treated as a DataFrame with a single named column.
The join is done on columns or indexes. If joining columns on
columns, the DataFrame indexes *will be ignored*. Otherwise if joining indexes
on indexes or indexes on a column or columns, the index will be passed on.
Expand Down
32 changes: 17 additions & 15 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
ArrayLike,
DtypeObj,
FrameOrSeries,
FrameOrSeriesUnion,
IndexLabel,
Suffixes,
)
Expand Down Expand Up @@ -81,15 +80,18 @@
from pandas.core.sorting import is_int64_overflow_possible

if TYPE_CHECKING:
from pandas import DataFrame
from pandas import (
DataFrame,
Series,
)
from pandas.core.arrays import DatetimeArray


@Substitution("\nleft : DataFrame")
@Substitution("\nleft : DataFrame or named Series")
@Appender(_merge_doc, indents=0)
def merge(
left: FrameOrSeriesUnion,
right: FrameOrSeriesUnion,
left: DataFrame | Series,
right: DataFrame | Series,
how: str = "inner",
on: IndexLabel | None = None,
left_on: IndexLabel | None = None,
Expand Down Expand Up @@ -322,8 +324,8 @@ def _merger(x, y) -> DataFrame:


def merge_asof(
left: DataFrame,
right: DataFrame,
left: DataFrame | Series,
right: DataFrame | Series,
on: IndexLabel | None = None,
left_on: IndexLabel | None = None,
right_on: IndexLabel | None = None,
Expand Down Expand Up @@ -362,8 +364,8 @@ def merge_asof(
Parameters
----------
left : DataFrame
right : DataFrame
left : DataFrame or named Series
right : DataFrame or named Series
on : label
Field name to join on. Must be found in both DataFrames.
The data MUST be ordered. Furthermore this must be a numeric column,
Expand Down Expand Up @@ -608,8 +610,8 @@ class _MergeOperation:

def __init__(
self,
left: FrameOrSeriesUnion,
right: FrameOrSeriesUnion,
left: DataFrame | Series,
right: DataFrame | Series,
how: str = "inner",
on: IndexLabel | None = None,
left_on: IndexLabel | None = None,
Expand Down Expand Up @@ -1599,8 +1601,8 @@ class _OrderedMerge(_MergeOperation):

def __init__(
self,
left: DataFrame,
right: DataFrame,
left: DataFrame | Series,
right: DataFrame | Series,
on: IndexLabel | None = None,
left_on: IndexLabel | None = None,
right_on: IndexLabel | None = None,
Expand Down Expand Up @@ -1704,8 +1706,8 @@ class _AsOfMerge(_OrderedMerge):

def __init__(
self,
left: DataFrame,
right: DataFrame,
left: DataFrame | Series,
right: DataFrame | Series,
on: IndexLabel | None = None,
left_on: IndexLabel | None = None,
right_on: IndexLabel | None = None,
Expand Down

0 comments on commit dc1c978

Please sign in to comment.