Skip to content

Commit 928ce5e

Browse files
committed
additional review edits
1 parent 02c659d commit 928ce5e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

doc/source/whatsnew/v0.23.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Other API Changes
438438
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
439439
- :class:`DateOffset` objects render more simply, e.g. "<DateOffset: days=1>" instead of "<DateOffset: kwds={'days': 1}>" (:issue:`19403`)
440440
- :func:`pandas.merge` provides a more informative error message when trying to merge on timezone-aware and timezone-naive columns (:issue:`15800`)
441-
- The default value of the ``ordered`` parameter for :class:`~pandas.api.types.CategoricalDtype` has changed from ``False`` to ``None``. Behavior should remain consistent for downstream objects, such as :class:`Categorical` (:issue:`18790`)
441+
- The default value of the ``ordered`` parameter for :class:`~pandas.api.types.CategoricalDtype` has changed from ``False`` to ``None`` to allow updating of ``categories`` without impacting ``ordered``. Behavior should remain consistent for downstream objects, such as :class:`Categorical` (:issue:`18790`)
442442

443443
.. _whatsnew_0230.deprecations:
444444

pandas/tests/dtypes/test_dtypes.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,22 @@ def test_same_categories_different_order(self):
644644
@pytest.mark.parametrize('ordered1', [True, False, None])
645645
@pytest.mark.parametrize('ordered2', [True, False, None])
646646
def test_categorical_equality(self, ordered1, ordered2):
647-
# same categories
647+
# same categories, same order
648+
# any combination of None/False are equal
649+
# True/True is the only combination with True that are equal
648650
c1 = CategoricalDtype(list('abc'), ordered1)
649651
c2 = CategoricalDtype(list('abc'), ordered2)
650652
result = c1 == c2
651-
expected = (ordered1 is ordered2) or not any([ordered1, ordered2])
653+
expected = bool(ordered1) is bool(ordered2)
654+
assert result is expected
655+
656+
# same categories, different order
657+
# any combination of None/False are equal (order doesn't matter)
658+
# any combination with True are not equal (different order of cats)
659+
c1 = CategoricalDtype(list('abc'), ordered1)
660+
c2 = CategoricalDtype(list('cab'), ordered2)
661+
result = c1 == c2
662+
expected = (bool(ordered1) is False) and (bool(ordered2) is False)
652663
assert result is expected
653664

654665
# different categories

0 commit comments

Comments
 (0)