Skip to content

TYP: join.pyi #40831

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
Apr 8, 2021
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
144 changes: 144 additions & 0 deletions pandas/_libs/join.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import numpy as np

def inner_join(
left: np.ndarray, # const intp_t[:]
right: np.ndarray, # const intp_t[:]
max_groups: int,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def left_outer_join(
left: np.ndarray, # const intp_t[:]
right: np.ndarray, # const intp_t[:]
max_groups: int,
sort: bool = True,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def full_outer_join(
left: np.ndarray, # const intp_t[:]
right: np.ndarray, # const intp_t[:]
max_groups: int,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def ffill_indexer(
indexer: np.ndarray # const intp_t[:]
) -> np.ndarray: ... # np.ndarray[np.intp]


def left_join_indexer_unique(
left: np.ndarray, # ndarray[join_t]
right: np.ndarray, # ndarray[join_t]
) -> np.ndarray: ... # np.ndarray[np.intp]


def left_join_indexer(
left: np.ndarray, # ndarray[join_t]
right: np.ndarray, # ndarray[join_t]
) -> tuple[
np.ndarray, # np.ndarray[join_t]
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def inner_join_indexer(
left: np.ndarray, # ndarray[join_t]
right: np.ndarray, # ndarray[join_t]
) -> tuple[
np.ndarray, # np.ndarray[join_t]
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def outer_join_indexer(
left: np.ndarray, # ndarray[join_t]
right: np.ndarray, # ndarray[join_t]
) -> tuple[
np.ndarray, # np.ndarray[join_t]
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def asof_join_backward_on_X_by_Y(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
left_by_values: np.ndarray, # by_t[:]
right_by_values: np.ndarray, # by_t[:]
allow_exact_matches: bool = True,
tolerance=None,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def asof_join_forward_on_X_by_Y(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
left_by_values: np.ndarray, # by_t[:]
right_by_values: np.ndarray, # by_t[:]
allow_exact_matches: bool = True,
tolerance=None,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def asof_join_nearest_on_X_by_Y(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
left_by_values: np.ndarray, # by_t[:]
right_by_values: np.ndarray, # by_t[:]
allow_exact_matches: bool = True,
tolerance=None,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def asof_join_backward(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
allow_exact_matches: bool = True,
tolerance=None,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def asof_join_forward(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
allow_exact_matches: bool = True,
tolerance=None,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...


def asof_join_nearest(
left_values: np.ndarray, # asof_t[:]
right_values: np.ndarray, # asof_t[:]
allow_exact_matches: bool = True,
tolerance=None,
) -> tuple[
np.ndarray, # np.ndarray[np.intp]
np.ndarray, # np.ndarray[np.intp]
]: ...
18 changes: 15 additions & 3 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,8 @@ def get_join_indexers(
"outer": libjoin.full_outer_join,
}[how]

return join_func(lkey, rkey, count, **kwargs)
# error: Cannot call function of unknown type
return join_func(lkey, rkey, count, **kwargs) # type: ignore[operator]


def restore_dropped_levels_multijoin(
Expand Down Expand Up @@ -1624,9 +1625,20 @@ def get_result(self) -> DataFrame:
self.left._info_axis, self.right._info_axis, self.suffixes
)

left_join_indexer: np.ndarray | None
right_join_indexer: np.ndarray | None

if self.fill_method == "ffill":
left_join_indexer = libjoin.ffill_indexer(left_indexer)
right_join_indexer = libjoin.ffill_indexer(right_indexer)
# error: Argument 1 to "ffill_indexer" has incompatible type
# "Optional[ndarray]"; expected "ndarray"
left_join_indexer = libjoin.ffill_indexer(
left_indexer # type: ignore[arg-type]
)
# error: Argument 1 to "ffill_indexer" has incompatible type
# "Optional[ndarray]"; expected "ndarray"
right_join_indexer = libjoin.ffill_indexer(
right_indexer # type: ignore[arg-type]
)
else:
left_join_indexer = left_indexer
right_join_indexer = right_indexer
Expand Down