Skip to content

Commit 253ed5d

Browse files
gfyoungjorisvandenbossche
authored andcommitted
CLN: Removed the return_type param in StringMethods.split (#13701)
Deprecated in #10085
1 parent bb6b5e5 commit 253ed5d

File tree

3 files changed

+4
-46
lines changed

3 files changed

+4
-46
lines changed

Diff for: doc/source/whatsnew/v0.19.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ Removal of prior version deprecations/changes
621621
- ``DataFrame.to_sql()`` has dropped the ``mysql`` option for the ``flavor`` parameter (:issue:`13611`)
622622
- ``pd.Index`` has dropped the ``diff`` method in favour of ``difference`` (:issue:`13669`)
623623

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

626627
Previous Behavior:

Diff for: pandas/core/strings.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from pandas.core.algorithms import take_1d
1616
import pandas.compat as compat
1717
from pandas.core.base import AccessorProperty, NoNewAttributesMixin
18-
from pandas.util.decorators import Appender, deprecate_kwarg
18+
from pandas.util.decorators import Appender
1919
import re
2020
import pandas.lib as lib
2121
import warnings
@@ -1401,8 +1401,6 @@ def cat(self, others=None, sep=None, na_rep=None):
14011401
result = str_cat(data, others=others, sep=sep, na_rep=na_rep)
14021402
return self._wrap_result(result, use_codes=(not self._is_categorical))
14031403

1404-
@deprecate_kwarg('return_type', 'expand', mapping={'series': False,
1405-
'frame': True})
14061404
@copy(str_split)
14071405
def split(self, pat=None, n=-1, expand=False):
14081406
result = str_split(self._data, pat, n=n)

Diff for: pandas/tests/test_strings.py

+2-43
Original file line numberDiff line numberDiff line change
@@ -1906,45 +1906,6 @@ def test_split_no_pat_with_nonzero_n(self):
19061906

19071907
def test_split_to_dataframe(self):
19081908
s = Series(['nosplit', 'alsonosplit'])
1909-
1910-
with tm.assert_produces_warning(FutureWarning):
1911-
result = s.str.split('_', return_type='frame')
1912-
1913-
exp = DataFrame({0: Series(['nosplit', 'alsonosplit'])})
1914-
tm.assert_frame_equal(result, exp)
1915-
1916-
s = Series(['some_equal_splits', 'with_no_nans'])
1917-
with tm.assert_produces_warning(FutureWarning):
1918-
result = s.str.split('_', return_type='frame')
1919-
exp = DataFrame({0: ['some', 'with'],
1920-
1: ['equal', 'no'],
1921-
2: ['splits', 'nans']})
1922-
tm.assert_frame_equal(result, exp)
1923-
1924-
s = Series(['some_unequal_splits', 'one_of_these_things_is_not'])
1925-
with tm.assert_produces_warning(FutureWarning):
1926-
result = s.str.split('_', return_type='frame')
1927-
exp = DataFrame({0: ['some', 'one'],
1928-
1: ['unequal', 'of'],
1929-
2: ['splits', 'these'],
1930-
3: [NA, 'things'],
1931-
4: [NA, 'is'],
1932-
5: [NA, 'not']})
1933-
tm.assert_frame_equal(result, exp)
1934-
1935-
s = Series(['some_splits', 'with_index'], index=['preserve', 'me'])
1936-
with tm.assert_produces_warning(FutureWarning):
1937-
result = s.str.split('_', return_type='frame')
1938-
exp = DataFrame({0: ['some', 'with'], 1: ['splits', 'index']},
1939-
index=['preserve', 'me'])
1940-
tm.assert_frame_equal(result, exp)
1941-
1942-
with tm.assertRaisesRegexp(ValueError, "expand must be"):
1943-
with tm.assert_produces_warning(FutureWarning):
1944-
s.str.split('_', return_type="some_invalid_type")
1945-
1946-
def test_split_to_dataframe_expand(self):
1947-
s = Series(['nosplit', 'alsonosplit'])
19481909
result = s.str.split('_', expand=True)
19491910
exp = DataFrame({0: Series(['nosplit', 'alsonosplit'])})
19501911
tm.assert_frame_equal(result, exp)
@@ -1973,8 +1934,7 @@ def test_split_to_dataframe_expand(self):
19731934
tm.assert_frame_equal(result, exp)
19741935

19751936
with tm.assertRaisesRegexp(ValueError, "expand must be"):
1976-
with tm.assert_produces_warning(FutureWarning):
1977-
s.str.split('_', return_type="some_invalid_type")
1937+
s.str.split('_', expand="not_a_boolean")
19781938

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

20011961
with tm.assertRaisesRegexp(ValueError, "expand must be"):
2002-
with tm.assert_produces_warning(FutureWarning):
2003-
idx.str.split('_', return_type="some_invalid_type")
1962+
idx.str.split('_', expand="not_a_boolean")
20041963

20051964
def test_rsplit_to_dataframe_expand(self):
20061965
s = Series(['nosplit', 'alsonosplit'])

0 commit comments

Comments
 (0)