From 54303dd91e4529ed274be59ddb50e91d9499f6e8 Mon Sep 17 00:00:00 2001 From: Krzysztof Chomski Date: Wed, 8 Nov 2017 21:43:09 +0100 Subject: [PATCH] BUG: fillna maximum recursion depth exceeded in cmp (GH18159). --- doc/source/whatsnew/v0.22.0.txt | 1 + pandas/core/internals.py | 5 +++-- pandas/tests/internals/test_internals.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.22.0.txt b/doc/source/whatsnew/v0.22.0.txt index a9f35fb4827926..dbc19a6b66d336 100644 --- a/doc/source/whatsnew/v0.22.0.txt +++ b/doc/source/whatsnew/v0.22.0.txt @@ -94,6 +94,7 @@ Documentation Changes Bug Fixes ~~~~~~~~~ +- BUG: fillna maximum recursion depth exceeded in cmp (GH18159). Conversion ^^^^^^^^^^ diff --git a/pandas/core/internals.py b/pandas/core/internals.py index ca4984cc166737..88c5de6e81f74e 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -1847,8 +1847,9 @@ def _can_hold_element(self, element): if tipo is not None: return (issubclass(tipo.type, (np.floating, np.integer)) and not issubclass(tipo.type, (np.datetime64, np.timedelta64))) - return (isinstance(element, (float, int, np.floating, np.int_)) and - not isinstance(element, (bool, np.bool_, datetime, timedelta, + return ( + isinstance(element, (float, int, np.floating, np.int_, np.long)) + and not isinstance(element, (bool, np.bool_, datetime, timedelta, np.datetime64, np.timedelta64))) def to_native_types(self, slicer=None, na_rep='', float_format=None, diff --git a/pandas/tests/internals/test_internals.py b/pandas/tests/internals/test_internals.py index 4c0c7d8598a8e6..66d9c2c69402c2 100644 --- a/pandas/tests/internals/test_internals.py +++ b/pandas/tests/internals/test_internals.py @@ -1222,6 +1222,7 @@ class TestCanHoldElement(object): @pytest.mark.parametrize('value, dtype', [ (1, 'i8'), (1.0, 'f8'), + (2**63, 'f8'), (1j, 'complex128'), (True, 'bool'), (np.timedelta64(20, 'ns'), '