Skip to content

Commit cf79529

Browse files
authored
type dataframe.combine (#1142)
1 parent d7be7c3 commit cf79529

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
10251025
self,
10261026
other: DataFrame,
10271027
func: Callable,
1028-
fill_value=...,
1028+
fill_value: Scalar | None = ...,
10291029
overwrite: _bool = ...,
10301030
) -> Self: ...
10311031
def combine_first(self, other: DataFrame) -> Self: ...

tests/test_frame.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,3 +4000,15 @@ def test_hashable_args() -> None:
40004000
# GH 906
40014001
@pd.api.extensions.register_dataframe_accessor("geo")
40024002
class GeoAccessor: ...
4003+
4004+
4005+
def test_combine() -> None:
4006+
df1 = pd.DataFrame({"A": [0, 0], "B": [4, 4]})
4007+
df2 = pd.DataFrame({"A": [1, 1], "B": [3, 3]})
4008+
take_smaller = lambda s1, s2: s1 if s1.sum() < s2.sum() else s2
4009+
assert_type(
4010+
check(
4011+
df1.combine(df2, take_smaller, fill_value=0, overwrite=False), pd.DataFrame
4012+
),
4013+
pd.DataFrame,
4014+
)

0 commit comments

Comments
 (0)