Skip to content

Commit 4ac23d6

Browse files
GH1043 Update _typing.pyi: add "cross" option to JoinHow (#1044)
* Update _typing.pyi: add "cross" option to JoinHow * Removed "cross" option from JoinHow and added it back to MergeHow * Replaced JoinHow with MergeHow in frame.join * Added a test for join "how" * Update test_frame.py: used check(assert_type pattern in unit test * Update test_frame.py Fix formatting
1 parent 02b0d7f commit 4ac23d6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ class DataFrame(NDFrame, OpsMixin):
15031503
self,
15041504
other: DataFrame | Series | list[DataFrame | Series],
15051505
on: _str | list[_str] | None = ...,
1506-
how: JoinHow = ...,
1506+
how: MergeHow = ...,
15071507
lsuffix: _str = ...,
15081508
rsuffix: _str = ...,
15091509
sort: _bool = ...,

tests/test_frame.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,16 @@ def test_join() -> None:
25042504
check(assert_type(left.join(right, validate="1:m"), pd.DataFrame), pd.DataFrame)
25052505

25062506

2507+
def test_types_join() -> None:
2508+
df1 = pd.DataFrame({"A": [1, 2], "B": ["test", "test"]})
2509+
df2 = pd.DataFrame({"C": [2, 3], "D": ["test", "test"]})
2510+
check(assert_type(df1.join(df2, how="cross"), pd.DataFrame), pd.DataFrame)
2511+
check(assert_type(df1.join(df2, how="inner"), pd.DataFrame), pd.DataFrame)
2512+
check(assert_type(df1.join(df2, how="outer"), pd.DataFrame), pd.DataFrame)
2513+
check(assert_type(df1.join(df2, how="left"), pd.DataFrame), pd.DataFrame)
2514+
check(assert_type(df1.join(df2, how="right"), pd.DataFrame), pd.DataFrame)
2515+
2516+
25072517
def test_types_ffill() -> None:
25082518
# GH 44
25092519
df = pd.DataFrame([[1, 2, 3]])

0 commit comments

Comments
 (0)