Skip to content

Commit 2cd4f81

Browse files
committed
Changes to .all()
1 parent ab94b7f commit 2cd4f81

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

pandas/core/dtypes/cast.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
""" routings for casting """
22

33
from datetime import datetime, timedelta
4-
from typing import Any, Union
54

65
import numpy as np
76

@@ -1334,13 +1333,3 @@ def maybe_cast_to_integer_array(arr, dtype, copy=False):
13341333
if is_integer_dtype(dtype) and (is_float_dtype(arr) or
13351334
is_object_dtype(arr)):
13361335
raise ValueError("Trying to coerce float values to integers")
1337-
1338-
1339-
def ensure_python_int(value: Union[int, Any]) -> int:
1340-
msg = "Wrong type {} for value {}"
1341-
try:
1342-
new_value = int(value)
1343-
assert (new_value == value)
1344-
except (TypeError, ValueError, AssertionError):
1345-
raise TypeError(msg.format(type(value), value))
1346-
return new_value

pandas/core/indexes/range.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pandas.compat.numpy import function as nv
1111
from pandas.util._decorators import Appender, cache_readonly
1212

13-
from pandas.core.dtypes import cast, concat as _concat
13+
from pandas.core.dtypes import concat as _concat
1414
from pandas.core.dtypes.common import (
1515
ensure_python_int, is_int64_dtype, is_integer, is_scalar,
1616
is_timedelta64_dtype)
@@ -337,7 +337,7 @@ def has_duplicates(self):
337337
def __contains__(self, key):
338338
hash(key)
339339
try:
340-
key = cast.ensure_python_int(key)
340+
key = ensure_python_int(key)
341341
except TypeError:
342342
return False
343343
return key in self._range
@@ -649,9 +649,7 @@ def __floordiv__(self, other):
649649
return self._int64index // other
650650

651651
def all(self):
652-
if 0 in self._range:
653-
return False
654-
return True
652+
return 0 not in self._range
655653

656654
def any(self):
657655
return any(self._range)

0 commit comments

Comments
 (0)