From 682f60b8eaed57702d00cd6ccc73cbc795a4363f Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 26 Jun 2020 10:47:31 +0100 Subject: [PATCH] CLN: remove redundant code in IndexOpsMixin.item --- pandas/core/base.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 813de491ffdb3..b62ef668df5e1 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -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 @@ -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")