Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: Hashable | None = ...,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some methods use Hashable for fill_value, others Scalar, I'm not sure. anyway for now in this PR I'm just going with what's in pandas

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Scalar | NAType | None . In the stubs, we want to promote "good" behavior, and Hashable is too wide. In addition, the docs say "fill value: scalar, default np.nan" . Maybe the pandas source should change??

) -> 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: Hashable | None = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 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)