Skip to content

TYP and DOC: pd.merge accepts Series #41594

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 6 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
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
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