You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If columns that are “enum” type want to be converted to “numeric” type, they should be converted to “character” first, then use “numeric”. Otherwise, the values may be converted to underlying factor values, not the expected mapped values.
User found that .asnumeric() may behave differently than expected. The new “numeric” values are based on the underlying values (not the mapped values).
h1. +Add to Docs:+
If columns that are “enum” type want to be converted to “numeric” type, they should be converted to “character” first, then use “numeric”. Otherwise, the values may be converted to underlying factor values, not the expected mapped values.
Python Example:
{noformat}prostate["column"] = prostate["column"].ascharacter().asnumeric(){noformat}
R Example:
{noformat}prostate[, 2] <- as.character(prostate[, 2])
prostate[, 2] <- as.numeric(prostate[, 2]){noformat}
This behavior is similar to R datatables.
Sections to consider adding to:
[https://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/frame.html?highlight=asnumeric#h2o.H2OFrame.asnumeric|https://docs.h2o.ai/h2o/latest-stable/h2o-py/docs/frame.html?highlight=asnumeric#h2o.H2OFrame.asnumeric|smart-link]
[https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/change-column-type.html?highlight=asnumeric|https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/change-column-type.html?highlight=asnumeric|smart-link]
[https://docs.h2o.ai/h2o/latest-stable/h2o-r/docs/reference/as.numeric.html|https://docs.h2o.ai/h2o/latest-stable/h2o-r/docs/reference/as.numeric.html|smart-link]
[https://docs.h2o.ai/h2o/latest-stable/h2o-r/docs/reference/h2o.asnumeric.html|https://docs.h2o.ai/h2o/latest-stable/h2o-r/docs/reference/h2o.asnumeric.html|smart-link]
h1. Background
User found that .asnumeric() may behave differently than expected. The new “numeric” values are based on the underlying values (not the mapped values).
{noformat}df1 = pd.DataFrame([[1.1, '1.1%'], [2, '2'], [3, '3']])
hframe1 = h2o.H2OFrame(df1, column_types=['real', 'enum'])
hframe1{noformat}
Output:
||0||1||
|1.1|1.1%|
|2|2|
|3|3|
{noformat}hframe1["1"] = hframe1["1"].gsub(pattern="%", replacement="")
hframe1["1"] = hframe1["1"].trim()
hframe1{noformat}
||0||1||
|1.1|1.1|
|2|2|
|3|3|
{noformat}hframe1.asnumeric(){noformat}
||0||1||
|1.1|{color:#6554c0}0{color}|
|2|1|
|3|2|
^ value 1.1 was converted to 0 (and other values become underlying values). This is similar to how R works.
Related issue: [https://h2oai.atlassian.net/browse/PUBDEV-8272|https://h2oai.atlassian.net/browse/PUBDEV-8272|smart-link]
The text was updated successfully, but these errors were encountered: