Skip to content

Commit

Permalink
Merge pull request modin-project#50 from intel-go/ienkovich/cat-codes…
Browse files Browse the repository at this point in the history
…-null

fix cat.codes for NULLs
  • Loading branch information
ienkovich authored Jun 23, 2020
2 parents 54c5df5 + f85e682 commit 0084e8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modin/experimental/engines/omnisci_on_ray/frame/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,12 @@ def cat_codes(self):

col = self.columns[-1]
exprs = self._index_exprs()
exprs[col] = OpExpr("KEY_FOR_STRING", [self.ref(col)], _get_dtype("int32"))
col_expr = self.ref(col)
code_expr = OpExpr("KEY_FOR_STRING", [col_expr], _get_dtype("int32"))
null_val = LiteralExpr(np.int32(-1))
exprs[col] = build_if_then_else(
col_expr.is_null(), null_val, code_expr, _get_dtype("int32")
)

return self.__constructor__(
columns=self.columns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def test_dt_month(self):

class TestCategory:
data = {
"a": ["str1", "str2", "str1", "str3", "str2"],
"a": ["str1", "str2", "str1", "str3", "str2", None],
}

def test_cat_codes(self):
Expand Down

0 comments on commit 0084e8d

Please sign in to comment.