Skip to content

Commit

Permalink
minor cleanups (pandas-dev#29798)
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 authored and proost committed Dec 19, 2019
1 parent 0225469 commit 55c6855
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ Performance improvements
- Performance improvement in :meth:`DataFrame.replace` when provided a list of values to replace (:issue:`28099`)
- Performance improvement in :meth:`DataFrame.select_dtypes` by using vectorization instead of iterating over a loop (:issue:`28317`)
- Performance improvement in :meth:`Categorical.searchsorted` and :meth:`CategoricalIndex.searchsorted` (:issue:`28795`)
- Performance improvement when searching for a scalar in a :meth:`Categorical` and the scalar is not found in the categories (:issue:`29750`)
- Performance improvement when comparing a :meth:`Categorical` with a scalar and the scalar is not found in the categories (:issue:`29750`)

.. _whatsnew_1000.bug_fixes:

Expand Down
10 changes: 2 additions & 8 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ def _cat_compare_op(op):

@unpack_zerodim_and_defer(opname)
def func(self, other):
# On python2, you can usually compare any type to any type, and
# Categoricals can be seen as a custom type, but having different
# results depending whether categories are the same or not is kind of
# insane, so be a bit stricter here and use the python3 idea of
# comparing only things of equal type.

if is_list_like(other) and len(other) != len(self):
# TODO: Could this fail if the categories are listlike objects?
raise ValueError("Lengths must match.")
Expand Down Expand Up @@ -840,8 +834,8 @@ def set_categories(self, new_categories, ordered=None, rename=False, inplace=Fal
On the other hand this methods does not do checks (e.g., whether the
old categories are included in the new categories on a reorder), which
can result in surprising changes, for example when using special string
dtypes on python3, which does not considers a S1 string equal to a
single char python string.
dtypes, which does not considers a S1 string equal to a single char
python string.
Parameters
----------
Expand Down

0 comments on commit 55c6855

Please sign in to comment.