Skip to content

TYP: _item_cache and _ixs #47506

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
Jun 27, 2022
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
8 changes: 4 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3558,16 +3558,16 @@ def T(self) -> DataFrame:
# ----------------------------------------------------------------------
# Indexing Methods

def _ixs(self, i: int, axis: int = 0):
def _ixs(self, i: int, axis: int = 0) -> Series:
"""
Parameters
----------
i : int
axis : int

Notes
-----
If slice passed, the resulting data will be a view.
Returns
-------
Series
"""
# irow
if axis == 0:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,7 @@ def __getstate__(self) -> dict[str, Any]:
}

@final
def __setstate__(self, state):
def __setstate__(self, state) -> None:
if isinstance(state, BlockManager):
self._mgr = state
elif isinstance(state, dict):
Expand Down Expand Up @@ -2047,7 +2047,7 @@ def __setstate__(self, state):
elif len(state) == 2:
raise NotImplementedError("Pre-0.12 pickles are no longer supported")

self._item_cache = {}
self._item_cache: dict[Hashable, Series] = {}

# ----------------------------------------------------------------------
# Rendering Methods
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def _take_with_is_copy(self, indices, axis=0) -> Series:
"""
return self.take(indices=indices, axis=axis)

def _ixs(self, i: int, axis: int = 0):
def _ixs(self, i: int, axis: int = 0) -> Any:
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't mind leaving it un-annotated but I'm also fine using Any.

Ideally Series becomes generic as done by @Dr-Irv in the pandas-stubs but that is probably something for the future.

"""
Return the i-th value or values in the Series by location.

Expand Down