Exploring & transforming H2O Data Frame in R and Python

Sometime you may need to ingest a dataset for building models and then your first task is to explore all the features and their type you have. Once that is done you may want to change the feature types to the one you want. Here is the code snippet in Python: df = h2o.import_file(‘https://raw.githubusercontent.com/h2oai/sparkling-water/master/examples/smalldata/prostate.csv’) df.types […]

Continue reading


Applying AND, OR, NOT conditions as filter into dataframe

Question: How to add conditions into data frame filters, to express the function (AND, OR, NOT)? For example, I have two flags: myData flag to be myData_flag myProx flag to be is_myProx_t_f. Conditions are defined as below: AND: is it data_myDatamyProx = data[(data[‘myData_flag’].isin([‘1’]),:)&&( data[‘is_myProx_t_f’].isin([‘1’]),:)]? OR: is it data_myDataOrmyProx = data[(data[‘myData_flag’].isin([‘1’]),:)||( data[‘is_myProx_t_f’].isin([‘1’]),:)]? NOT: is it data_NonemyDatamyProx = […]

Continue reading


Maintaining column names after applying function on data frame

Sometime when we apply a function on a data frame the column names are changed. Here is an example: // Creating a new data frame and then converting it to H2O data frame c_names = [‘Num’, ‘Prediction’] data1 = np.array([[1, 0.12], [2, 0.43], [3,0.90], [4,0.002], [5,0.52]]) df = h2o.H2OFrame().from_python(data1, destination_frame=‘df’, column_names=c_names) // Printing H2O Dataframe […]

Continue reading