# Path: sksurv/column.py
# def encode_categorical(table, columns=None, **kwargs):
#     """
#     Encode categorical columns with `M` categories into `M-1` columns according
#     to the one-hot scheme.
# 
#     Parameters
#     ----------
#     table : pandas.DataFrame
#         Table with categorical columns to encode.
# 
#     columns : list-like, optional, default: None
#         Column names in the DataFrame to be encoded.
#         If `columns` is None then all the columns with
#         `object` or `category` dtype will be converted.
# 
#     allow_drop : boolean, optional, default: True
#         Whether to allow dropping categorical columns that only consist
#         of a single category.
# 
#     Returns
#     -------
#     encoded : pandas.DataFrame
#         Table with categorical columns encoded as numeric.
#         Numeric columns in the input table remain unchanged.
#     """
#     if isinstance(table, pandas.Series):
#         if not is_categorical_dtype(table.dtype) and not table.dtype.char == "O":
#             raise TypeError("series must be of categorical dtype, but was {}".format(table.dtype))
#         return _encode_categorical_series(table, **kwargs)
# 
#     def _is_categorical_or_object(series):
#         return is_categorical_dtype(series.dtype) or series.dtype.char == "O"
# 
#     if columns is None:
#         # for columns containing categories
#         columns_to_encode = {nam for nam, s in table.iteritems() if _is_categorical_or_object(s)}
#     else:
#         columns_to_encode = set(columns)
# 
#     items = []
#     for name, series in table.iteritems():
#         if name in columns_to_encode:
#             series = _encode_categorical_series(series, **kwargs)
#             if series is None:
#                 continue
#         items.append(series)
# 
#     # concat columns of tables
#     new_table = pandas.concat(items, axis=1, copy=False)
#     return new_table


from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.utils.validation import _check_feature_names_in, check_is_fitted
from .column import encode_categorical
        Includes names of non-categorical columns.

    n_features_in_ : int
        Number of features seen during ``fit``.

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during ``fit``. Defined only when `X`
        has feature names that are all strings.
    """
    def __init__(self, allow_drop=True):
        self.allow_drop = allow_drop

    def fit(self, X, y=None):  # pylint: disable=unused-argument
        """Retrieve categorical columns.

        Parameters
        ----------
        X : pandas.DataFrame
            Data to encode.
        y :
            Ignored. For compatibility with Pipeline.
        Returns
        -------
        self : object
            Returns self
        """
        self.fit_transform(X)
        return self

    def _encode(self, X, columns_to_encode):

# Path: sksurv/column.py
# def encode_categorical(table, columns=None, **kwargs):
#     """
#     Encode categorical columns with `M` categories into `M-1` columns according
#     to the one-hot scheme.
# 
#     Parameters
#     ----------
#     table : pandas.DataFrame
#         Table with categorical columns to encode.
# 
#     columns : list-like, optional, default: None
#         Column names in the DataFrame to be encoded.
#         If `columns` is None then all the columns with
#         `object` or `category` dtype will be converted.
# 
#     allow_drop : boolean, optional, default: True
#         Whether to allow dropping categorical columns that only consist
#         of a single category.
# 
#     Returns
#     -------
#     encoded : pandas.DataFrame
#         Table with categorical columns encoded as numeric.
#         Numeric columns in the input table remain unchanged.
#     """
#     if isinstance(table, pandas.Series):
#         if not is_categorical_dtype(table.dtype) and not table.dtype.char == "O":
#             raise TypeError("series must be of categorical dtype, but was {}".format(table.dtype))
#         return _encode_categorical_series(table, **kwargs)
# 
#     def _is_categorical_or_object(series):
#         return is_categorical_dtype(series.dtype) or series.dtype.char == "O"
# 
#     if columns is None:
#         # for columns containing categories
#         columns_to_encode = {nam for nam, s in table.iteritems() if _is_categorical_or_object(s)}
#     else:
#         columns_to_encode = set(columns)
# 
#     items = []
#     for name, series in table.iteritems():
#         if name in columns_to_encode:
#             series = _encode_categorical_series(series, **kwargs)
#             if series is None:
#                 continue
#         items.append(series)
# 
#     # concat columns of tables
#     new_table = pandas.concat(items, axis=1, copy=False)
#     return new_table


# Path: sksurv/preprocessing.py
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.utils.validation import _check_feature_names_in, check_is_fitted
from .column import encode_categorical

        Includes names of non-categorical columns.

    n_features_in_ : int
        Number of features seen during ``fit``.

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during ``fit``. Defined only when `X`
        has feature names that are all strings.
    """
    def __init__(self, allow_drop=True):
        self.allow_drop = allow_drop

    def fit(self, X, y=None):  # pylint: disable=unused-argument
        """Retrieve categorical columns.

        Parameters
        ----------
        X : pandas.DataFrame
            Data to encode.
        y :
            Ignored. For compatibility with Pipeline.
        Returns
        -------
        self : object
            Returns self
        """
        self.fit_transform(X)
        return self

    def _encode(self, X, columns_to_encode):

        return encode_categorical(X, columns=columns_to_encode, allow_drop=self.allow_drop)