h2o-py/h2o/frame.py
def generatePandaEnumCols(pandaFtrain, cname, nrows, domainL):
    """
    For an H2O Enum column, we perform one-hot-encoding here and add one more column, "missing(NA)" to it.

    :param pandaFtrain: panda frame derived from H2OFrame
    :param cname: column name of enum col
    :param nrows: number of rows of enum col
    :return: panda frame with enum col encoded correctly for native XGBoost
    """
    import numpy as np
    import pandas as pd
    
    cmissingNames=[cname+".missing(NA)"]
    tempnp = np.zeros((nrows,1), dtype=np.int)
    # check for nan and assign it correct value
    colVals = pandaFtrain[cname]
    for ind in range(nrows):
        try:
            if not(colVals[ind] in domainL):
                tempnp[ind]=1
        except ValueError:
            pass
    zeroFrame = pd.DataFrame(tempnp)
    zeroFrame.columns=cmissingNames
    temp = pd.get_dummies(pandaFtrain[cname], prefix=cname, drop_first=False)
    tempNames = list(temp)  # get column names
    colLength = len(tempNames)
    newNames = ['a']*colLength

    for ind in range(0,colLength):
        newNames[ind]=cname+"_"+domainL[ind]
    ftemp = temp[newNames]
    ctemp = pd.concat([ftemp, zeroFrame], axis=1)
    return ctemp
def generatePandaEnumCols(pandaFtrain, cname, nrows, domainL):
    """
    For an H2O Enum column, we perform one-hot-encoding here and add one more column, "missing(NA)" to it.

    :param pandaFtrain: panda frame derived from H2OFrame
    :param cname: column name of enum col
    :param nrows: number of rows of enum col
    :return: panda frame with enum col encoded correctly for native XGBoost
    """
    import numpy as np
    import pandas as pd
    
    cmissingNames=[cname+".missing(NA)"]
    tempnp = np.zeros((nrows,1), dtype=np.int)
    # check for nan and assign it correct value
    colVals = pandaFtrain[cname]
    for ind in range(nrows):
        try:
            if not(colVals[ind] in domainL):
                tempnp[ind]=1
        except ValueError:
            pass
    zeroFrame = pd.DataFrame(tempnp)
    zeroFrame.columns=cmissingNames
    temp = pd.get_dummies(pandaFtrain[cname], prefix=cname, drop_first=False)
    tempNames = list(temp)  # get column names
    colLength = len(tempNames)
    newNames = ['a']*colLength

    for ind in range(0,colLength):
        newNames[ind]=cname+"_"+domainL[ind]
    ftemp = temp[newNames]
    ctemp = pd.concat([ftemp, zeroFrame], axis=1)
    return ctemp
For an H2O Enum column, we perform one-hot-encoding here and add one more column, "missing(NA)" to it.

    :param pandaFtrain: panda frame derived from H2OFrame
    :param cname: column name of enum col
    :param nrows: number of rows of enum col
    :return: panda frame with enum col encoded correctly for native XGBoost