Skip to content

Commit

Permalink
fixed failing test, ready for initial review
Browse files Browse the repository at this point in the history
  • Loading branch information
skirui-source committed Jun 30, 2021
1 parent 06a75fa commit 3ece4ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 6 additions & 5 deletions python/cudf/cudf/core/column/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
is_string_dtype,
)


def str_to_boolean(column: StringColumn):
"""Takes in string column and returns boolean column """
return (column.str().len() > cudf.Scalar(0, dtype="int8")).fillna(False)


_str_to_numeric_typecast_functions = {
np.dtype("int8"): str_cast.stoi8,
np.dtype("int16"): str_cast.stoi16,
Expand Down Expand Up @@ -219,11 +225,6 @@
ParentType = Union["cudf.Series", "cudf.core.index.BaseIndex"]


def str_to_boolean(column):
"""Takes in string column and returns boolean column """
return (column.str.len() > 0).fillna(False)


class StringMethods(ColumnMethodsMixin):
def __init__(self, column, parent=None):
"""
Expand Down
6 changes: 1 addition & 5 deletions python/cudf/cudf/tests/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ def test_string_astype(dtype):
ps = pd.Series(data)
gs = cudf.Series(data)

# Pandas str --> bool typecasting always returns True if there's a string
if dtype.startswith("bool"):
expect = ps == "True"
else:
expect = ps.astype(dtype)
expect = ps.astype(dtype)
got = gs.astype(dtype)

assert_eq(expect, got)
Expand Down

0 comments on commit 3ece4ca

Please sign in to comment.