Skip to content

CLN: Removed the return_type param in StringMethods.split #13701

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ Removal of prior version deprecations/changes
- ``pd.Categorical`` has dropped the ``levels`` attribute in favour of ``categories`` (:issue:`8376`)
- ``DataFrame.to_sql()`` has dropped the ``mysql`` option for the ``flavor`` parameter (:issue:`13611`)

- ``str.split`` has dropped the ``return_type`` parameter in favor of ``expand`` (:issue:`13701`)
- Removal of the legacy time rules (offset aliases), deprecated since 0.17.0 (this has been alias since 0.8.0) (:issue:`13590`)

Previous Behavior:
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pandas.core.algorithms import take_1d
import pandas.compat as compat
from pandas.core.base import AccessorProperty, NoNewAttributesMixin
from pandas.util.decorators import Appender, deprecate_kwarg
from pandas.util.decorators import Appender
import re
import pandas.lib as lib
import warnings
Expand Down Expand Up @@ -1401,8 +1401,6 @@ def cat(self, others=None, sep=None, na_rep=None):
result = str_cat(data, others=others, sep=sep, na_rep=na_rep)
return self._wrap_result(result, use_codes=(not self._is_categorical))

@deprecate_kwarg('return_type', 'expand', mapping={'series': False,
'frame': True})
@copy(str_split)
def split(self, pat=None, n=-1, expand=False):
result = str_split(self._data, pat, n=n)
Expand Down
45 changes: 2 additions & 43 deletions pandas/tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,45 +1906,6 @@ def test_split_no_pat_with_nonzero_n(self):

def test_split_to_dataframe(self):
s = Series(['nosplit', 'alsonosplit'])

with tm.assert_produces_warning(FutureWarning):
result = s.str.split('_', return_type='frame')

exp = DataFrame({0: Series(['nosplit', 'alsonosplit'])})
tm.assert_frame_equal(result, exp)

s = Series(['some_equal_splits', 'with_no_nans'])
with tm.assert_produces_warning(FutureWarning):
result = s.str.split('_', return_type='frame')
exp = DataFrame({0: ['some', 'with'],
1: ['equal', 'no'],
2: ['splits', 'nans']})
tm.assert_frame_equal(result, exp)

s = Series(['some_unequal_splits', 'one_of_these_things_is_not'])
with tm.assert_produces_warning(FutureWarning):
result = s.str.split('_', return_type='frame')
exp = DataFrame({0: ['some', 'one'],
1: ['unequal', 'of'],
2: ['splits', 'these'],
3: [NA, 'things'],
4: [NA, 'is'],
5: [NA, 'not']})
tm.assert_frame_equal(result, exp)

s = Series(['some_splits', 'with_index'], index=['preserve', 'me'])
with tm.assert_produces_warning(FutureWarning):
result = s.str.split('_', return_type='frame')
exp = DataFrame({0: ['some', 'with'], 1: ['splits', 'index']},
index=['preserve', 'me'])
tm.assert_frame_equal(result, exp)

with tm.assertRaisesRegexp(ValueError, "expand must be"):
with tm.assert_produces_warning(FutureWarning):
s.str.split('_', return_type="some_invalid_type")

def test_split_to_dataframe_expand(self):
s = Series(['nosplit', 'alsonosplit'])
result = s.str.split('_', expand=True)
exp = DataFrame({0: Series(['nosplit', 'alsonosplit'])})
Copy link
Contributor

Choose a reason for hiding this comment

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

these should still work w/o the argument, so leave the tests themselves

Copy link
Member Author

Choose a reason for hiding this comment

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

They are duplicates essentially with the tests that follow, which is why I removed them.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, ok

tm.assert_frame_equal(result, exp)
Expand Down Expand Up @@ -1973,8 +1934,7 @@ def test_split_to_dataframe_expand(self):
tm.assert_frame_equal(result, exp)

with tm.assertRaisesRegexp(ValueError, "expand must be"):
with tm.assert_produces_warning(FutureWarning):
s.str.split('_', return_type="some_invalid_type")
s.str.split('_', expand="not_a_boolean")

def test_split_to_multiindex_expand(self):
idx = Index(['nosplit', 'alsonosplit'])
Expand All @@ -1999,8 +1959,7 @@ def test_split_to_multiindex_expand(self):
self.assertEqual(result.nlevels, 6)

with tm.assertRaisesRegexp(ValueError, "expand must be"):
with tm.assert_produces_warning(FutureWarning):
idx.str.split('_', return_type="some_invalid_type")
idx.str.split('_', expand="not_a_boolean")

def test_rsplit_to_dataframe_expand(self):
s = Series(['nosplit', 'alsonosplit'])
Expand Down