8000 API: change default for sep in str.cat (in docstring) by h-vetinari · Pull Request #23443 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

API: change default for sep in str.cat (in docstring) #23443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 6, 2018
Prev Previous commit
Next Next commit
Review (jschendel & jreback)
  • Loading branch information
h-vetinari committed Nov 2, 2018
commit d361dceeba1ac28f372bc5157de97718cda69290
10 changes: 8 additions & 2 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2074,10 +2074,10 @@ def cat(self, others=None, sep='', na_rep=None, join=None):

If others is None, the method returns the concatenation of all
strings in the calling Series/Index.
sep : string, default ''
sep : str, default ''
The separator between the different elements/columns. By default
the empty string `''` is used.
na_rep : string or None, default None
na_rep : str or None, default None
Representation that is inserted for all missing values:

- If `na_rep` is None, and `others` is None, missing values in the
Expand Down Expand Up @@ -2197,6 +2197,12 @@ def cat(self, others=None, sep='', na_rep=None, join=None):

if isinstance(others, compat.string_types):
raise ValueError("Did you mean to supply a `sep` keyword?")
if sep is None:
warnings.warn('Passing `sep=None` to .str.cat is deprecated and '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls remove this and just update as I suggested.

'will be removed in a future version. Please use '
'`sep=''` to pass the default explicitly',
FutureWarning, stacklevel=2)
sep = ''

if isinstance(self._orig, Index):
data = Series(self._orig, index=self._orig)
Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def test_str_cat_raises_intuitive_error(self, box):
with tm.assert_raises_regex(ValueError, message):
s.str.cat(' ')

# GH 23443
with tm.assert_produces_warning(expected_warning=FutureWarning):
# FutureWarning to switch to default sep='' (instead of None)
s.str.cat(sep=None)

@pytest.mark.parametrize('dtype_target', ['object', 'category'])
@pytest.mark.parametrize('dtype_caller', ['object', 'category'])
@pytest.mark.parametrize('box', [Series, Index])
Expand Down
0