Skip to content

Commit 188f92e

Browse files
committed
cleanups
1 parent 51b363e commit 188f92e

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

doc/source/whatsnew/v2.3.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Other enhancements
3737
updated to work correctly with NumPy >= 2 (:issue:`57739`)
3838
- :meth:`Series.str.decode` result now has ``StringDtype`` when ``future.infer_string`` is True (:issue:`60709`)
3939
- :meth:`~Series.to_hdf` and :meth:`~DataFrame.to_hdf` now round-trip with ``StringDtype`` (:issue:`60663`)
40-
- The :meth:`~Series.cumsum`, :meth:`~Series.cummin`, and :meth:`~Series.cummax` reductions are now implemented for ``StringDtype`` columns (:issue:`60633`, :issue:`???`)
40+
- The :meth:`~Series.cumsum`, :meth:`~Series.cummin`, and :meth:`~Series.cummax` reductions are now implemented for ``StringDtype`` columns (:issue:`60633`, :issue:`60633`)
4141
- The :meth:`~Series.sum` reduction is now implemented for ``StringDtype`` columns (:issue:`59853`)
4242

4343
.. ---------------------------------------------------------------------------

pandas/core/arrays/string_.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
)
5050

5151
from pandas.core import (
52+
missing,
5253
nanops,
5354
ops,
5455
)
@@ -907,8 +908,6 @@ def _str_accumulate(
907908
) -> StringArray:
908909
"""
909910
Accumulate implementation for strings, see `_accumulate` docstring for details.
910-
911-
pyarrow.compute does not implement these methods for strings.
912911
"""
913912
if name == "cumprod":
914913
msg = f"operation '{name}' not supported for dtype '{self.dtype}'"
@@ -924,8 +923,6 @@ def _str_accumulate(
924923
"cummax": np.maximum.accumulate,
925924
}[name]
926925

927-
from pandas.core import missing
928-
929926
if self._hasna:
930927
na_mask = isna(ndarray)
931928
if np.all(na_mask):

pandas/tests/apply/test_str.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,10 @@ def test_agg_cython_table_series(series, func, expected):
161161
),
162162
),
163163
)
164-
def test_agg_cython_table_transform_series(request, series, func, expected):
164+
def test_agg_cython_table_transform_series(series, func, expected):
165165
# GH21224
166166
# test transforming functions in
167167
# pandas.core.base.SelectionMixin._cython_table (cumprod, cumsum)
168-
# if series.dtype == "string" and func == "cumsum" and not HAS_PYARROW:
169-
# request.applymarker(
170-
# pytest.mark.xfail(
171-
# raises=NotImplementedError,
172-
# reason="TODO(infer_string) cumsum not yet implemented for string",
173-
# )
174-
# )
175168
warn = None if isinstance(func, str) else FutureWarning
176169
with tm.assert_produces_warning(warn, match="is currently using Series.*"):
177170
result = series.agg(func)

pandas/tests/groupby/test_categorical.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ def test_observed(request, using_infer_string, observed):
325325
# gh-8138 (back-compat)
326326
# gh-8869
327327

328-
# if using_infer_string and not observed:
329-
# # TODO(infer_string) this fails with filling the string column with 0
330-
# request.applymarker(pytest.mark.xfail(reason="TODO(infer_string)"))
328+
if using_infer_string and not observed:
329+
# TODO(infer_string) this fails with filling the string column with 0
330+
request.applymarker(pytest.mark.xfail(reason="TODO(infer_string)"))
331331

332332
cat1 = Categorical(["a", "a", "b", "b"], categories=["a", "b", "z"], ordered=True)
333333
cat2 = Categorical(["c", "d", "c", "d"], categories=["c", "d", "y"], ordered=True)
@@ -355,12 +355,9 @@ def test_observed(request, using_infer_string, observed):
355355
)
356356
result = gb.sum()
357357
if not observed:
358-
fill_value = "" if using_infer_string else 0
359358
expected = cartesian_product_for_groupers(
360-
expected, [cat1, cat2], list("AB"), fill_value=fill_value
359+
expected, [cat1, cat2], list("AB"), fill_value=0
361360
)
362-
print(result)
363-
print(expected)
364361
tm.assert_frame_equal(result, expected)
365362

366363

pandas/tests/series/test_cumulative.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,11 @@ def test_cumprod_timedelta(self):
265265
([pd.NA, pd.NA, pd.NA], "cummax", False, [pd.NA, pd.NA, pd.NA]),
266266
],
267267
)
268-
def test_cum_methods_pyarrow_strings(
268+
def test_cum_methods_ea_strings(
269269
self, string_dtype_no_object, data, op, skipna, expected_data
270270
):
271-
# https://github.com/pandas-dev/pandas/pull/60633
271+
# https://github.com/pandas-dev/pandas/pull/60633 - pyarrow
272+
# https://github.com/pandas-dev/pandas/pull/60938 - Python
272273
ser = pd.Series(data, dtype=string_dtype_no_object)
273274
method = getattr(ser, op)
274275
expected = pd.Series(expected_data, dtype=string_dtype_no_object)

0 commit comments

Comments
 (0)