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: 2 additions & 1 deletion doc/source/whatsnew/v0.15.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Bug Fixes
- Bug in ``Categorical`` not created properly with ``Series.to_frame()`` (:issue:`8626`)
- Bug in coercing in astype of a ``Categorical`` of a passed ``pd.Categorical`` (this now raises ``TypeError`` correctly), (:issue:`8626`)
- Bug in ``cut``/``qcut`` when using ``Series`` and ``retbins=True`` (:issue:`8589`)
- Bug in comparing ``Categorical`` of datetime raising when being compared to a scalar datetime (:issue:`8687`)



Expand All @@ -165,7 +166,7 @@ Bug Fixes



- Bug in numeric index operations of add/sub with Float/Index Index with numpy arrays (:issue:`8608`
- Bug in numeric index operations of add/sub with Float/Index Index with numpy arrays (:issue:`8608`)
- Bug in setitem with empty indexer and unwanted coercion of dtypes (:issue:`8669`)


Expand Down
4 changes: 2 additions & 2 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from warnings import warn
import types

from pandas import compat
from pandas import compat, lib
from pandas.compat import u

from pandas.core.algorithms import factorize
Expand Down Expand Up @@ -42,7 +42,7 @@ def f(self, other):
# In other series, the leads to False, so do that here too
ret[na_mask] = False
return ret
elif np.isscalar(other):
elif lib.isscalar(other):
if other in self.categories:
i = self.categories.get_loc(other)
return getattr(self._codes, op)(i)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,11 @@ def test_deprecated_levels(self):

self.assertFalse(LooseVersion(pd.__version__) >= '0.18')

def test_datetime_categorical_comparison(self):
dt_cat = pd.Categorical(pd.date_range('2014-01-01', periods=3))
self.assert_numpy_array_equal(dt_cat > dt_cat[0], [False, True, True])
self.assert_numpy_array_equal(dt_cat[0] < dt_cat, [False, True, True])


class TestCategoricalAsBlock(tm.TestCase):
_multiprocess_can_split_ = True
Expand Down