Skip to content

type align #1138

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 3 commits into from
Mar 4, 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
6 changes: 1 addition & 5 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
axis: Axis | None = ...,
level: Level | None = ...,
copy: _bool = ...,
fill_value=...,
method: FillnaOptions | None = ...,
limit: int | None = ...,
fill_axis: Axis = ...,
broadcast_axis: Axis | None = ...,
fill_value: Scalar | NAType | None = ...,
) -> tuple[Self, NDFrameT]: ...
def reindex(
self,
Expand Down
6 changes: 1 addition & 5 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1034,11 +1034,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
axis: Axis | None = ...,
level: Level | None = ...,
copy: _bool = ...,
fill_value=...,
method: FillnaOptions | None = ...,
limit: int | None = ...,
fill_axis: AxisIndex = ...,
broadcast_axis: AxisIndex | None = ...,
fill_value: Scalar | NAType | None = ...,
) -> tuple[Series, Series]: ...
@overload
def rename(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3662,6 +3662,9 @@ def test_align() -> None:
aligned_df0, aligned_s0 = df0.align(s0, axis="index")
check(assert_type(aligned_df0, pd.DataFrame), pd.DataFrame)
check(assert_type(aligned_s0, "pd.Series[str]"), pd.Series, str)
aligned_df0, aligned_s0 = df0.align(s0, axis="index", fill_value=0)
check(assert_type(aligned_df0, pd.DataFrame), pd.DataFrame)
check(assert_type(aligned_s0, "pd.Series[str]"), pd.Series, str)

s1 = pd.Series(data={"A": "A", "D": "D"})
aligned_df0, aligned_s1 = df0.align(s1, axis="columns")
Expand Down
11 changes: 11 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3672,3 +3672,14 @@ def test_info() -> None:
check(assert_type(s.info(show_counts=True), None), type(None))
check(assert_type(s.info(show_counts=False), None), type(None))
check(assert_type(s.info(show_counts=None), None), type(None))


def test_align() -> None:
s0 = pd.Series(data={0: 1, 3: 3, 5: 5})
s1 = pd.Series(data={0: 1, 2: 2})
aligned_s0, aligned_s1 = s0.align(s1)
check(assert_type(aligned_s0, pd.Series), pd.Series)
check(assert_type(aligned_s1, pd.Series), pd.Series)
aligned_s0, aligned_s1 = s0.align(s1, fill_value=0, axis=0, level=0, copy=False)
check(assert_type(aligned_s0, pd.Series), pd.Series)
check(assert_type(aligned_s1, pd.Series), pd.Series)