Skip to content

Commit a158a74

Browse files
authored
REF: remove unnecessary string mixins (#62155)
1 parent 4f286ca commit a158a74

File tree

4 files changed

+8
-284
lines changed

4 files changed

+8
-284
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
validate_indices,
7474
)
7575
from pandas.core.nanops import check_below_min_count
76-
from pandas.core.strings.base import BaseStringArrayMethods
7776

7877
from pandas.io._util import _arrow_dtype_mapping
7978
from pandas.tseries.frequencies import to_offset
@@ -237,7 +236,6 @@ class ArrowExtensionArray(
237236
OpsMixin,
238237
ExtensionArraySupportsAnyAll,
239238
ArrowStringArrayMixin,
240-
BaseStringArrayMethods,
241239
):
242240
"""
243241
Pandas ExtensionArray backed by a PyArrow ChunkedArray.

pandas/core/strings/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,21 @@
22
Implementation of pandas.Series.str and its interface.
33
44
* strings.accessor.StringMethods : Accessor for Series.str
5-
* strings.base.BaseStringArrayMethods: Mixin ABC for EAs to implement str methods
65
76
Most methods on the StringMethods accessor follow the pattern:
87
98
1. extract the array from the series (or index)
109
2. Call that array's implementation of the string method
1110
3. Wrap the result (in a Series, index, or DataFrame)
1211
13-
Pandas extension arrays implementing string methods should inherit from
14-
pandas.core.strings.base.BaseStringArrayMethods. This is an ABC defining
15-
the various string methods. To avoid namespace clashes and pollution,
12+
To avoid namespace clashes and pollution,
1613
these are prefixed with `_str_`. So ``Series.str.upper()`` calls
1714
``Series.array._str_upper()``. The interface isn't currently public
1815
to other string extension arrays.
1916
"""
2017
# Pandas current implementation is in ObjectStringArrayMixin. This is designed
2118
# to work on object-dtype ndarrays.
2219
#
23-
# BaseStringArrayMethods
2420
# - ObjectStringArrayMixin
2521
# - StringArray
2622
# - NumpyExtensionArray

pandas/core/strings/base.py

Lines changed: 0 additions & 274 deletions
This file was deleted.

pandas/core/strings/object_array.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
from pandas.core.dtypes.common import pandas_dtype
2222
from pandas.core.dtypes.missing import isna
2323

24-
from pandas.core.strings.base import BaseStringArrayMethods
25-
2624
if TYPE_CHECKING:
2725
from collections.abc import (
2826
Callable,
@@ -35,7 +33,7 @@
3533
)
3634

3735

38-
class ObjectStringArrayMixin(BaseStringArrayMethods):
36+
class ObjectStringArrayMixin:
3937
"""
4038
String Methods operating on object-dtype ndarrays.
4139
"""
@@ -44,6 +42,12 @@ def __len__(self) -> int:
4442
# For typing, _str_map relies on the object being sized.
4543
raise NotImplementedError
4644

45+
def _str_getitem(self, key):
46+
if isinstance(key, slice):
47+
return self._str_slice(start=key.start, stop=key.stop, step=key.step)
48+
else:
49+
return self._str_get(key)
50+
4751
def _str_map(
4852
self,
4953
f,

0 commit comments

Comments
 (0)