Skip to content

CLN: remove redundant code in IndexOpsMixin.item #35008

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
Jun 26, 2020
Merged
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: 0 additions & 8 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
is_list_like,
is_object_dtype,
is_scalar,
needs_i8_conversion,
)
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
from pandas.core.dtypes.missing import isna
Expand Down Expand Up @@ -656,13 +655,6 @@ def item(self):
ValueError
If the data is not length-1.
"""
if not (
is_extension_array_dtype(self.dtype) or needs_i8_conversion(self.dtype)
):
# numpy returns ints instead of datetime64/timedelta64 objects,
# which we need to wrap in Timestamp/Timedelta/Period regardless.
return self._values.item()

if len(self) == 1:
return next(iter(self))
raise ValueError("can only convert an array of size 1 to a Python scalar")
Expand Down