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
Modify documentation at the following location [https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/change-column-type.html|https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/change-column-type.html|smart-link] as following:
Update “asfactor” function header comments to:
{noformat}"""
Convert column/columns in the current frame to categoricals.
#Single column
df = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
df['cylinders'] = df['cylinders'].asfactor()
df['cylinders'].describe()
#Multiple columns
df = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
df[['cylinders','economy_20mpg']] = df[['cylinders','economy_20mpg']].asfactor()
df[['cylinders','economy_20mpg']].describe()
"""
{noformat}
Modify documentation at the following location [https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/change-column-type.html|https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-munging/change-column-type.html|smart-link] as following:
{noformat}import h2o
h2o.init()
import the cars dataset:
cars_df = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
#df = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
#df[['cylinders','economy_20mpg']] = df[['cylinders','economy_20mpg']].asfactor()
#df[['cylinders','economy_20mpg']].describe()
#boston = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/gbm_test/BostonHousing.csv")
check the column type for the
cylinders
columnprint(cars_df["cylinders"].isnumeric())
#[True]
change the column type to a factor
cars_df['cylinders'] = cars_df['cylinders'].asfactor()
verify that the column is now a factor
print(cars_df["cylinders"].isfactor())
#[True]
change the column type back to numeric
cars_df["cylinders"] = cars_df["cylinders"].asnumeric()
verify that the column is numeric and not a factor
print(cars_df["cylinders"].isfactor())
#[False]
print(cars_df["cylinders"].isnumeric())
#[True]
#Change multiple columns to a factor
cars_df = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
cars_df[['cylinders','economy_20mpg']] = cars_df[['cylinders','economy_20mpg']].asfactor()
verify that the column is now a factor
print(cars_df["cylinders"].isfactor())
print(cars_df["economy_20mpg"].isfactor()){noformat}
The text was updated successfully, but these errors were encountered: