Commit 16228763 authored by Shengpu Tang (tangsp)'s avatar Shengpu Tang (tangsp)
Browse files

HOTFIX-20201211: discretization

- discretization might not work properly in certain cases when it has a type of object rather than float
parent cab4ded8
......@@ -159,7 +159,7 @@ def smart_qcut_dummify(x, bin_edges, use_ordinal_encoding=False):
out.loc[m, col_names[i]] = (z.loc[m] >= bin_edge).astype(int)
out = pd.concat([out, pd.get_dummies(z.where(~m, np.nan), prefix=z.name)], axis=1)
else:
z.loc[m] = pd.cut(z.loc[m].to_numpy(), bin_edges, duplicates='drop', include_lowest=True)
z.loc[m] = pd.cut(z.loc[m].astype(float).to_numpy(), bin_edges, duplicates='drop', include_lowest=True)
out = pd.get_dummies(z, prefix=z.name)
else:
out = pd.get_dummies(x, prefix=x.name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment