Skip to content

Commit 060364b

Browse files
jbrockmendelyeshsurya
authored andcommitted
REF: remove Categorical._shallow_copy (pandas-dev#41030)
1 parent 3f43a82 commit 060364b

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

pandas/core/indexes/base.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -2982,12 +2982,7 @@ def _union(self, other: Index, sort):
29822982

29832983
elif not other.is_unique:
29842984
# other has duplicates
2985-
2986-
# error: Argument 1 to "union_with_duplicates" has incompatible type
2987-
# "Union[ExtensionArray, ndarray]"; expected "ndarray"
2988-
# error: Argument 2 to "union_with_duplicates" has incompatible type
2989-
# "Union[ExtensionArray, ndarray]"; expected "ndarray"
2990-
result = algos.union_with_duplicates(lvals, rvals) # type: ignore[arg-type]
2985+
result = algos.union_with_duplicates(lvals, rvals)
29912986
return _maybe_try_sort(result, sort)
29922987

29932988
# Self may have duplicates
@@ -3002,9 +2997,7 @@ def _union(self, other: Index, sort):
30022997
other_diff = rvals.take(missing)
30032998
result = concat_compat((lvals, other_diff))
30042999
else:
3005-
# error: Incompatible types in assignment (expression has type
3006-
# "Union[ExtensionArray, ndarray]", variable has type "ndarray")
3007-
result = lvals # type: ignore[assignment]
3000+
result = lvals
30083001

30093002
if not self.is_monotonic or not other.is_monotonic:
30103003
result = _maybe_try_sort(result, sort)

pandas/core/indexes/category.py

-17
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pandas._config import get_option
1212

1313
from pandas._libs import index as libindex
14-
from pandas._libs.lib import no_default
1514
from pandas._typing import (
1615
ArrayLike,
1716
Dtype,
@@ -234,22 +233,6 @@ def __new__(
234233

235234
# --------------------------------------------------------------------
236235

237-
@doc(Index._shallow_copy)
238-
def _shallow_copy(
239-
self,
240-
values: Categorical,
241-
name: Hashable = no_default,
242-
) -> CategoricalIndex:
243-
name = self._name if name is no_default else name
244-
245-
if values is not None:
246-
# In tests we only get here with Categorical objects that
247-
# have matching .ordered, and values.categories a subset of
248-
# our own. However we do _not_ have a dtype match in general.
249-
values = Categorical(values, dtype=self.dtype)
250-
251-
return super()._shallow_copy(values=values, name=name)
252-
253236
def _is_dtype_compat(self, other) -> Categorical:
254237
"""
255238
*this is an internal non-public method*

0 commit comments

Comments
 (0)