Skip to content

Commit 04694a5

Browse files
committed
Revert cat-output-for-cat-caller propsal
1 parent b66015c commit 04694a5

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

doc/source/whatsnew/v0.23.0.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,7 @@ In v.0.23 `join` will default to None (meaning no alignment), but this default w
325325
s.str.cat(t)
326326
s.str.cat(t, join='left', na_rep='-')
327327

328-
Furthermore:
329-
- meth:`Series.str.cat` now works as well for ``CategoricalIndex`` as well (previously raised a ``ValueError``; see :issue:`20842`)
330-
- If concatenating with something (i.e. `others is not None`) the resulting ``Series``/``Index`` will now remain categorical if the calling ``Series``/``Index`` is categorical (see :issue:`20843`)
328+
Furthermore, meth:`Series.str.cat` now works for ``CategoricalIndex`` as well (previously raised a ``ValueError``; see :issue:`20842`).
331329

332330
.. _whatsnew_0230.enhancements.astype_category:
333331

pandas/core/strings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,11 +2217,10 @@ def cat(self, others=None, sep=None, na_rep=None, join=None):
22172217
# str_cat discards index
22182218
res = str_cat(data, others=others, sep=sep, na_rep=na_rep)
22192219

2220-
dtype = 'category' if self._is_categorical else None
22212220
if isinstance(self._orig, Index):
2222-
res = Index(res, dtype=dtype)
2221+
res = Index(res)
22232222
else: # Series
2224-
res = Series(res, index=data.index, dtype=dtype)
2223+
res = Series(res, index=data.index)
22252224
return res
22262225

22272226
@copy(str_split)

pandas/tests/series/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ def test_str_accessor_api_for_categorical(self):
608608

609609
# str functions, which need special arguments
610610
special_func_defs = [
611+
('cat', (list("zyxw"),), {"sep": ","}),
611612
('center', (10,), {}),
612613
('contains', ("a",), {}),
613614
('count', ("a",), {}),
@@ -643,12 +644,11 @@ def test_str_accessor_api_for_categorical(self):
643644
]
644645
_special_func_names = [f[0] for f in special_func_defs]
645646

646-
# * cat tested extensively with categorical data in test_strings.py
647647
# * get, join: they need a individual elements of type lists, but
648648
# we can't make a categorical with lists as individual categories.
649649
# -> `s.str.split(" ").astype("category")` will error!
650650
# * `translate` has different interfaces for py2 vs. py3
651-
_ignore_names = ["cat", "get", "join", "translate"]
651+
_ignore_names = ["get", "join", "translate"]
652652

653653
str_func_names = [f for f in dir(s.str) if not (
654654
f.startswith("_") or

pandas/tests/test_strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_str_cat_categorical(self, series_or_index,
228228
s = Series(s)
229229
t = Index(['b', 'a', 'b', 'c'], dtype=dtype_target)
230230

231-
exp = Index(['ab', 'aa', 'bb', 'ac'], dtype=dtype_caller)
231+
exp = Index(['ab', 'aa', 'bb', 'ac'])
232232
if series_or_index == 'series':
233233
exp = Series(exp)
234234

0 commit comments

Comments
 (0)