Skip to content
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

Fix default value of str.split expand parameter. #10457

Merged
merged 2 commits into from
Mar 27, 2022
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
10 changes: 2 additions & 8 deletions python/cudf/cudf/core/column/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ def split(
self,
pat: str = None,
n: int = -1,
expand: bool = None,
expand: bool = False,
regex: bool = None,
) -> SeriesOrIndex:
"""
Expand Down Expand Up @@ -2414,9 +2414,6 @@ def split(
2 <NA> <NA> <NA> <NA> <NA>
"""

if expand is None:
expand = False

if expand not in (True, False):
raise ValueError(
f"expand parameter accepts only : [True, False], "
Expand Down Expand Up @@ -2464,7 +2461,7 @@ def rsplit(
self,
pat: str = None,
n: int = -1,
expand: bool = None,
expand: bool = False,
regex: bool = None,
) -> SeriesOrIndex:
"""
Expand Down Expand Up @@ -2593,9 +2590,6 @@ def rsplit(
2 <NA> <NA>
"""

if expand is None:
expand = False

if expand not in (True, False):
raise ValueError(
f"expand parameter accepts only : [True, False], "
Expand Down
10 changes: 5 additions & 5 deletions python/cudf/cudf/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def test_string_upper(ps_gs):
)
@pytest.mark.parametrize("pat", [None, " ", "-"])
@pytest.mark.parametrize("n", [-1, 0, 1, 3, 10])
@pytest.mark.parametrize("expand", [True, False, None])
@pytest.mark.parametrize("expand", [True, False])
def test_string_split(data, pat, n, expand):
ps = pd.Series(data, dtype="str")
gs = cudf.Series(data, dtype="str")
Expand All @@ -967,7 +967,7 @@ def test_string_split(data, pat, n, expand):
)
@pytest.mark.parametrize("pat", [None, " ", "\\-+", "\\s+"])
@pytest.mark.parametrize("n", [-1, 0, 1, 3, 10])
@pytest.mark.parametrize("expand", [True, False, None])
@pytest.mark.parametrize("expand", [True, False])
def test_string_split_re(data, pat, n, expand):
ps = pd.Series(data, dtype="str")
gs = cudf.Series(data, dtype="str")
Expand Down Expand Up @@ -1510,7 +1510,7 @@ def test_strings_partition(data):
],
)
@pytest.mark.parametrize("n", [-1, 2, 1, 9])
@pytest.mark.parametrize("expand", [True, False, None])
@pytest.mark.parametrize("expand", [True, False])
def test_strings_rsplit(data, n, expand):
gs = cudf.Series(data)
ps = pd.Series(data)
Expand All @@ -1531,7 +1531,7 @@ def test_strings_rsplit(data, n, expand):


@pytest.mark.parametrize("n", [-1, 0, 1, 3, 10])
@pytest.mark.parametrize("expand", [True, False, None])
@pytest.mark.parametrize("expand", [True, False])
def test_string_rsplit_re(n, expand):
data = ["a b", " c ", " d", "e ", "f"]
ps = pd.Series(data, dtype="str")
Expand Down Expand Up @@ -1566,7 +1566,7 @@ def test_string_rsplit_re(n, expand):
],
)
@pytest.mark.parametrize("n", [-1, 2, 1, 9])
@pytest.mark.parametrize("expand", [True, False, None])
@pytest.mark.parametrize("expand", [True, False])
def test_strings_split(data, n, expand):
gs = cudf.Series(data)
ps = pd.Series(data)
Expand Down