def _mode(x, def_fill=ImputerMixin._def_fill):
"""Get the most common value in a 1d
H2OFrame. Ties will be handled in a non-specified
manner.
Parameters
----------
x : ``H2OFrame``, shape=(n_samples, 1)
The 1d frame from which to derive the mode
"""
idx = x.as_data_frame(use_pandas=True)[x.columns[0]].value_counts().index
# if the most common is null, then return the next most common.
# if there is no next common (i.e., 100% null) then we return the def_fill
return idx[0] if not pd.isnull(idx[0]) else idx[1] if idx.shape[0] > 1 else def_fill
评论列表
文章目录