Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v0.21.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Documentation Changes

Bug Fixes
~~~~~~~~~
-


Conversion
^^^^^^^^^^
Expand All @@ -65,6 +67,7 @@ Conversion
- Bug in :meth:`IntervalIndex.copy` when copying and ``IntervalIndex`` with non-default ``closed`` (:issue:`18339`)
- Bug in :func:`DataFrame.to_dict` where columns of datetime that are tz-aware were not converted to required arrays when used with ``orient='records'``, raising``TypeError` (:issue:`18372`)
- Bug in :class:`DateTimeIndex` and :meth:`date_range` where mismatching tz-aware ``start`` and ``end`` timezones would not raise an err if ``end.tzinfo`` is None (:issue:`18431`)
- Bug in :meth:`Series.fillna` which raised when passed a long integer on Python 2 (:issue:`18159`).
-

Indexing
Expand Down
14 changes: 9 additions & 5 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1847,8 +1847,10 @@ 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,
Expand Down Expand Up @@ -1896,9 +1898,11 @@ def _can_hold_element(self, element):
if tipo is not None:
return issubclass(tipo.type,
(np.floating, np.integer, np.complexfloating))
return (isinstance(element,
(float, int, complex, np.float_, np.int_)) and
not isinstance(element, (bool, np.bool_)))
return (
isinstance(
element,
(float, int, complex, np.float_, np.int_, compat.long))
and not isinstance(element, (bool, np.bool_)))

def should_store(self, value):
return issubclass(value.dtype.type, np.complexfloating)
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/internals/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,9 @@ class TestCanHoldElement(object):
@pytest.mark.parametrize('value, dtype', [
(1, 'i8'),
(1.0, 'f8'),
(2**63, 'f8'),
(1j, 'complex128'),
(2**63, 'complex128'),
(True, 'bool'),
(np.timedelta64(20, 'ns'), '<m8[ns]'),
(np.datetime64(20, 'ns'), '<M8[ns]'),
Expand Down