code: def _get_dummies_1d(data, allow_drop=True):
      # Series avoids inconsistent NaN handling
      cat = pd.Categorical(data)
      levels = cat.categories
      number_of_cols = len(levels)
  
      # if all NaN or only one level
      if allow_drop and number_of_cols < 2:
          logging.getLogger(__package__).warning(
              f"dropped categorical variable {data.name!r}, because it has only {number_of_cols} values"
          )
          return
      if number_of_cols == 0:
          return None, levels
  
      dummy_mat = np.eye(number_of_cols).take(cat.codes, axis=0)
  
      # reset NaN GH4446
      dummy_mat[cat.codes == -1] = np.nan
  
      return dummy_mat, levels
  
file_path: scikit-survival/sksurv/column.py
imports: import logging
  import numpy
  import pandas
  from pandas.api.types import CategoricalDtype, is_object_dtype
label_desc: Use image node_id 6 for calling a global function with example usage: _get_dummies_1d(data, allow_drop) and returns: dummy_mat,  levels, None,  levels