Skip to content

type dataframe.combine #1142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
other: DataFrame,
func: Callable,
fill_value=...,
fill_value: Scalar | None = ...,
overwrite: _bool = ...,
) -> Self: ...
def combine_first(self, other: DataFrame) -> Self: ...
Expand Down
12 changes: 12 additions & 0 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4000,3 +4000,15 @@ def test_hashable_args() -> None:
# GH 906
@pd.api.extensions.register_dataframe_accessor("geo")
class GeoAccessor: ...


def test_combine() -> None:
df1 = pd.DataFrame({"A": [0, 0], "B": [4, 4]})
df2 = pd.DataFrame({"A": [1, 1], "B": [3, 3]})
take_smaller = lambda s1, s2: s1 if s1.sum() < s2.sum() else s2
assert_type(
check(
df1.combine(df2, take_smaller, fill_value=0, overwrite=False), pd.DataFrame
),
pd.DataFrame,
)