Skip to content

[mypy] Dataframe.Join with "cross" option for "how" argument throws error even though it's valid #1043

Closed
@brzegorzTesco

Description

@brzegorzTesco

Describe the bug
Using a "cross" join makes mypy throw a warning.

To Reproduce
Create a file example.py with following contents:

import pandas as pd

df1 = pd.DataFrame({"A":[1,2], "B": ["test", "test"]})
df2 = pd.DataFrame({"C":[2, 3], "D": ["test", "test"]})
df3 = df1.join(df2,how="cross")
print(df3)

Run mypy on it: "mypy example.py "

Output:
example.py:5: error: Argument "how" to "join" of "DataFrame" has incompatible type "Literal['cross']"; expected "Literal['left', 'right', 'outer', 'inner']" [arg-type]
Found 1 error in 1 file (checked 1 source file)

Expected output:
output with 0 errors

Please complete the following information:

  • OS: MacOs
  • OS Version: Sonoma 14.6
  • python version: 3.11.10
  • version of type checker: mypy 1.11.2
  • version of installed pandas-stubs: 2.2.2.240603

Additional context
Add any other context about the problem here.

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