Closed
Description
Describe the bug
Performing a cross join with two dataframes with df.merge(..., how="cross", ...)
creates a typing error `Type "Literal['cross']" cannot be assigned to type "MergeHow"
To Reproduce
Minimal example
import pandas as pd
df1 = pd.DataFrame(data={"a": [1, 2, 3]})
df2 = pd.DataFrame(data={"b": ["x", "y", "z"]})
df3 = df1.merge(df2, how="cross")
Pyright
Found 1 source file
pyright 1.1.270
[...]
[...]/cross_merge.py:6:26 - error: Argument of type "Literal['cross']" cannot be assigned to parameter "how" of type "MergeHow" in function "merge"
Type "Literal['cross']" cannot be assigned to type "MergeHow"
"Literal['cross']" cannot be assigned to type "Literal['left']"
"Literal['cross']" cannot be assigned to type "Literal['right']"
"Literal['cross']" cannot be assigned to type "Literal['outer']"
"Literal['cross']" cannot be assigned to type "Literal['inner']"
Please complete the following information:
- OS: MacOS
- OS Version: 12.5.1
- python version: 3.10.5
- version of type checker:
pyright 1.1.270
- version of installed
pandas-stubs
:1.4.4.220906
Additional context
L231: _typing.pyi
pandas DataFrame.merge docs - describes how="cross"
option.
Metadata
Metadata
Assignees
Labels
No labels