Skip to content

pd.merge allows Series as first argument #60

@Dr-Irv

Description

@Dr-Irv

Despite not being documented, the following works:

import pandas as pd

df1 = pd.DataFrame([["a", 1], ["b", 2]], columns=["let", "num"]).set_index("let")

s2 = df1["num"]

res = pd.merge(s2, df1, left_index=True, right_index=True)

print(res)

pylance 2021.5.3 reports

Argument of type "Series[Dtype@__getitem__]" cannot be assigned to parameter "left" of type "DataFrame" in function "merge"
  "Series[Dtype@__getitem__]" is incompatible with "DataFrame"

Basically, a Series can be the first argument to the various pd.merge() functions.

PR to follow. Will also do a pandas PR to fix the docs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions