diff --git a/doc/source/whatsnew/v0.21.1.txt b/doc/source/whatsnew/v0.21.1.txt index 3d4850b334ff9a..e1610937396f4c 100644 --- a/doc/source/whatsnew/v0.21.1.txt +++ b/doc/source/whatsnew/v0.21.1.txt @@ -56,6 +56,8 @@ Documentation Changes Bug Fixes ~~~~~~~~~ +- Bug in :meth:`fillna` where maximum recursion depth gets exceeded in comparison (:issue:`18159`). + Conversion ^^^^^^^^^^ diff --git a/pandas/core/internals.py b/pandas/core/internals.py index 1d1d71be16c009..45ce847089370e 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_, compat.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 a22d0174947e13..ac78def824b3e2 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'), '