
    0Ph*                       d Z ddlZddlmZmZ ddlmZ ddlmZ ddl	m
Z
mZ ddlZddlmZ dd	lmZmZmZ dd
lmZmZmZ ddlmZ ddlmZ ddlmZ ddlmZm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZB g dZCdZD G d dee6          ZEd ZFd ZGd ZHdddd d!d!d"d#ZI G d$ d%          ZJ G d& d'e          ZKd( ZLd)eMd*eMd+eMd,eMfd-ZNdS ).z
The :mod:`sklearn.compose._column_transformer` module implements utilities
to work with heterogeneous data and to apply different transformers to
different columns.
    N)CounterUserList)partial)chain)IntegralReal)sparse   )TransformerMixin_fit_contextclone)_fit_transform_one_name_estimators_transform_one)FunctionTransformer)Bunch)_VisualBlock)_determine_key_type_get_column_indices_safe_indexing)METHODS)
HasMethodsHiddenInterval
StrOptions)_get_container_adapter_get_output_config_safe_set_output)get_tags)MetadataRouterMethodMapping_raise_for_params_routing_enabledprocess_routing)_BaseComposition)Paralleldelayed)_check_feature_names_check_feature_names_in_check_n_features_get_feature_names_is_pandas_df_num_samplescheck_arraycheck_is_fitted)ColumnTransformermake_column_transformermake_column_selectorz1D data passed to a transformer that expects 2D data. Try to specify the column selection as a list of one item instead of a scalar.c            	            e Zd ZU dZe ee          g eddh           eddg           eddg          g e	e
ddd	
          gedgedgdgdeegdgdZeed<   dddddddddZed             Zej        d             Zdd fd
Zd4dZd Zd Zd Zd Zd Zd Zd  Zed!             Zd" Zd5d#Z d$ Z!d% Z"d& Z#d' Z$d( Z%d) Z&d5d*Z' e(d+          d5d,            Z)d- Z*d. Z+d/ Z,d0 Z-d1 Z.d2 Z/ fd3Z0 xZ1S )6r0   aT+  Applies transformers to columns of an array or pandas DataFrame.

    This estimator allows different columns or column subsets of the input
    to be transformed separately and the features generated by each transformer
    will be concatenated to form a single feature space.
    This is useful for heterogeneous or columnar data, to combine several
    feature extraction mechanisms or transformations into a single transformer.

    Read more in the :ref:`User Guide <column_transformer>`.

    .. versionadded:: 0.20

    Parameters
    ----------
    transformers : list of tuples
        List of (name, transformer, columns) tuples specifying the
        transformer objects to be applied to subsets of the data.

        name : str
            Like in Pipeline and FeatureUnion, this allows the transformer and
            its parameters to be set using ``set_params`` and searched in grid
            search.
        transformer : {'drop', 'passthrough'} or estimator
            Estimator must support :term:`fit` and :term:`transform`.
            Special-cased strings 'drop' and 'passthrough' are accepted as
            well, to indicate to drop the columns or to pass them through
            untransformed, respectively.
        columns :  str, array-like of str, int, array-like of int,                 array-like of bool, slice or callable
            Indexes the data on its second axis. Integers are interpreted as
            positional columns, while strings can reference DataFrame columns
            by name.  A scalar string or int should be used where
            ``transformer`` expects X to be a 1d array-like (vector),
            otherwise a 2d array will be passed to the transformer.
            A callable is passed the input data `X` and can return any of the
            above. To select multiple columns by name or dtype, you can use
            :obj:`make_column_selector`.

    remainder : {'drop', 'passthrough'} or estimator, default='drop'
        By default, only the specified columns in `transformers` are
        transformed and combined in the output, and the non-specified
        columns are dropped. (default of ``'drop'``).
        By specifying ``remainder='passthrough'``, all remaining columns that
        were not specified in `transformers`, but present in the data passed
        to `fit` will be automatically passed through. This subset of columns
        is concatenated with the output of the transformers. For dataframes,
        extra columns not seen during `fit` will be excluded from the output
        of `transform`.
        By setting ``remainder`` to be an estimator, the remaining
        non-specified columns will use the ``remainder`` estimator. The
        estimator must support :term:`fit` and :term:`transform`.
        Note that using this feature requires that the DataFrame columns
        input at :term:`fit` and :term:`transform` have identical order.

    sparse_threshold : float, default=0.3
        If the output of the different transformers contains sparse matrices,
        these will be stacked as a sparse matrix if the overall density is
        lower than this value. Use ``sparse_threshold=0`` to always return
        dense.  When the transformed output consists of all dense data, the
        stacked result will be dense, and this keyword will be ignored.

    n_jobs : int, default=None
        Number of jobs to run in parallel.
        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
        for more details.

    transformer_weights : dict, default=None
        Multiplicative weights for features per transformer. The output of the
        transformer is multiplied by these weights. Keys are transformer names,
        values the weights.

    verbose : bool, default=False
        If True, the time elapsed while fitting each transformer will be
        printed as it is completed.

    verbose_feature_names_out : bool, str or Callable[[str, str], str], default=True

        - If True, :meth:`ColumnTransformer.get_feature_names_out` will prefix
          all feature names with the name of the transformer that generated that
          feature. It is equivalent to setting
          `verbose_feature_names_out="{transformer_name}__{feature_name}"`.
        - If False, :meth:`ColumnTransformer.get_feature_names_out` will not
          prefix any feature names and will error if feature names are not
          unique.
        - If ``Callable[[str, str], str]``,
          :meth:`ColumnTransformer.get_feature_names_out` will rename all the features
          using the name of the transformer. The first argument of the callable is the
          transformer name and the second argument is the feature name. The returned
          string will be the new feature name.
        - If ``str``, it must be a string ready for formatting. The given string will
          be formatted using two field names: ``transformer_name`` and ``feature_name``.
          e.g. ``"{feature_name}__{transformer_name}"``. See :meth:`str.format` method
          from the standard library for more info.

        .. versionadded:: 1.0

        .. versionchanged:: 1.6
            `verbose_feature_names_out` can be a callable or a string to be formatted.

    force_int_remainder_cols : bool, default=True
        Force the columns of the last entry of `transformers_`, which
        corresponds to the "remainder" transformer, to always be stored as
        indices (int) rather than column names (str). See description of the
        `transformers_` attribute for details.

        .. note::
            If you do not access the list of columns for the remainder columns
            in the `transformers_` fitted attribute, you do not need to set
            this parameter.

        .. versionadded:: 1.5

        .. versionchanged:: 1.7
           The default value for `force_int_remainder_cols` will change from
           `True` to `False` in version 1.7.

    Attributes
    ----------
    transformers_ : list
        The collection of fitted transformers as tuples of (name,
        fitted_transformer, column). `fitted_transformer` can be an estimator,
        or `'drop'`; `'passthrough'` is replaced with an equivalent
        :class:`~sklearn.preprocessing.FunctionTransformer`. In case there were
        no columns selected, this will be the unfitted transformer. If there
        are remaining columns, the final element is a tuple of the form:
        ('remainder', transformer, remaining_columns) corresponding to the
        ``remainder`` parameter. If there are remaining columns, then
        ``len(transformers_)==len(transformers)+1``, otherwise
        ``len(transformers_)==len(transformers)``.

        .. versionchanged:: 1.5
            If there are remaining columns and `force_int_remainder_cols` is
            True, the remaining columns are always represented by their
            positional indices in the input `X` (as in older versions). If
            `force_int_remainder_cols` is False, the format attempts to match
            that of the other transformers: if all columns were provided as
            column names (`str`), the remaining columns are stored as column
            names; if all columns were provided as mask arrays (`bool`), so are
            the remaining columns; in all other cases the remaining columns are
            stored as indices (`int`).

    named_transformers_ : :class:`~sklearn.utils.Bunch`
        Read-only attribute to access any transformer by given name.
        Keys are transformer names and values are the fitted transformer
        objects.

    sparse_output_ : bool
        Boolean flag indicating whether the output of ``transform`` is a
        sparse matrix or a dense numpy array, which depends on the output
        of the individual transformers and the `sparse_threshold` keyword.

    output_indices_ : dict
        A dictionary from each transformer name to a slice, where the slice
        corresponds to indices in the transformed output. This is useful to
        inspect which transformer is responsible for which transformed
        feature(s).

        .. versionadded:: 1.0

    n_features_in_ : int
        Number of features seen during :term:`fit`. Only defined if the
        underlying transformers expose such an attribute when fit.

        .. versionadded:: 0.24

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during :term:`fit`. Defined only when `X`
        has feature names that are all strings.

        .. versionadded:: 1.0

    See Also
    --------
    make_column_transformer : Convenience function for
        combining the outputs of multiple transformer objects applied to
        column subsets of the original feature space.
    make_column_selector : Convenience function for selecting
        columns based on datatype or the columns name with a regex pattern.

    Notes
    -----
    The order of the columns in the transformed feature matrix follows the
    order of how the columns are specified in the `transformers` list.
    Columns of the original feature matrix that are not specified are
    dropped from the resulting transformed feature matrix, unless specified
    in the `passthrough` keyword. Those columns specified with `passthrough`
    are added at the right to the output of the transformers.

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.compose import ColumnTransformer
    >>> from sklearn.preprocessing import Normalizer
    >>> ct = ColumnTransformer(
    ...     [("norm1", Normalizer(norm='l1'), [0, 1]),
    ...      ("norm2", Normalizer(norm='l1'), slice(2, 4))])
    >>> X = np.array([[0., 1., 2., 2.],
    ...               [1., 1., 0., 1.]])
    >>> # Normalizer scales each row of X to unit norm. A separate scaling
    >>> # is applied for the two first and two last elements of each
    >>> # row independently.
    >>> ct.fit_transform(X)
    array([[0. , 1. , 0.5, 0.5],
           [0.5, 0.5, 0. , 1. ]])

    :class:`ColumnTransformer` can be configured with a transformer that requires
    a 1d array by setting the column to a string:

    >>> from sklearn.feature_extraction.text import CountVectorizer
    >>> from sklearn.preprocessing import MinMaxScaler
    >>> import pandas as pd   # doctest: +SKIP
    >>> X = pd.DataFrame({
    ...     "documents": ["First item", "second one here", "Is this the last?"],
    ...     "width": [3, 4, 5],
    ... })  # doctest: +SKIP
    >>> # "documents" is a string which configures ColumnTransformer to
    >>> # pass the documents column as a 1d array to the CountVectorizer
    >>> ct = ColumnTransformer(
    ...     [("text_preprocess", CountVectorizer(), "documents"),
    ...      ("num_preprocess", MinMaxScaler(), ["width"])])
    >>> X_trans = ct.fit_transform(X)  # doctest: +SKIP

    For a more detailed example of usage, see
    :ref:`sphx_glr_auto_examples_compose_plot_column_transformer_mixed_types.py`.
    droppassthroughfit	transformfit_transformr      both)closedNverbosebooleantransformers	remaindersparse_thresholdn_jobstransformer_weightsr<   verbose_feature_names_outforce_int_remainder_cols_parameter_constraints333333?FT)r@   rA   rB   rC   r<   rD   rE   c                v    || _         || _        || _        || _        || _        || _        || _        || _        d S Nr>   )	selfr?   r@   rA   rB   rC   r<   rD   rE   s	            c/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/compose/_column_transformer.py__init__zColumnTransformer.__init__2  sG     )" 0#6 )B&(@%%%    c                 b    	 d | j         D             S # t          t          f$ r
 | j         cY S w xY w)aS  
        Internal list of transformer only containing the name and
        transformers, dropping the columns.

        DO NOT USE: This is for the implementation of get_params via
        BaseComposition._get_params which expects lists of tuples of len 2.

        To iterate through the transformers, use ``self._iter`` instead.
        c                     g | ]
\  }}}||fS  rP   .0nametrans_s       rK   
<listcomp>z3ColumnTransformer._transformers.<locals>.<listcomp>S  s"    JJJndE1T5MJJJrM   )r?   	TypeError
ValueErrorrJ   s    rK   _transformerszColumnTransformer._transformersG  sM    	%JJ8IJJJJ:& 	% 	% 	%$$$$	%s    ..c                     	 d t          || j                  D             | _        dS # t          t          f$ r || _        Y dS w xY w)zDO NOT USE: This is for the implementation of set_params via
        BaseComposition._get_params which gives lists of tuples of len 2.
        c                 ,    g | ]\  \  }}\  }}}|||fS rP   rP   )rR   rS   rT   rU   cols        rK   rV   z3ColumnTransformer._transformers.<locals>.<listcomp>]  s=     ! ! !0]dEKQ3 uc"! ! !rM   N)zipr?   rW   rX   )rJ   values     rK   rZ   zColumnTransformer._transformersW  sn    
	&! !47t?P4Q4Q! ! !D :& 	& 	& 	& %D	&s   $( AAr7   c          	         t                                          |           d t          | j        t	          | dg                     D             }|D ]}t          ||           | j        dvrt          | j        |           | S )a  Set the output container when `"transform"` and `"fit_transform"` are called.

        Calling `set_output` will set the output of all estimators in `transformers`
        and `transformers_`.

        Parameters
        ----------
        transform : {"default", "pandas", "polars"}, default=None
            Configure output of `transform` and `fit_transform`.

            - `"default"`: Default output format of a transformer
            - `"pandas"`: DataFrame output
            - `"polars"`: Polars output
            - `None`: Transform configuration is unchanged

            .. versionadded:: 1.4
                `"polars"` option was added.

        Returns
        -------
        self : estimator instance
            Estimator instance.
        r`   c              3   *   K   | ]\  }}}|d v
|V  dS    r4   r5   NrP   )rR   rU   rT   s      rK   	<genexpr>z/ColumnTransformer.set_output.<locals>.<genexpr>~  sD       
 
5! 333	  4333
 
rM   transformers_rd   )super
set_outputr   r?   getattrr   r@   )rJ   r7   r?   rT   	__class__s       rK   rh   zColumnTransformer.set_outputd  s    0 	Y///
 
$!74"#E#E   
 
 
 " 	9 	9EUi88888>!888T^yAAAArM   c                 0    |                      d|          S )a  Get parameters for this estimator.

        Returns the parameters given in the constructor as well as the
        estimators contained within the `transformers` of the
        `ColumnTransformer`.

        Parameters
        ----------
        deep : bool, default=True
            If True, will return the parameters for this estimator and
            contained subobjects that are estimators.

        Returns
        -------
        params : dict
            Parameter names mapped to their values.
        rZ   )deep)_get_params)rJ   rl   s     rK   
get_paramszColumnTransformer.get_params  s    $ d;;;rM   c                       | j         di | | S )a  Set the parameters of this estimator.

        Valid parameter keys can be listed with ``get_params()``. Note that you
        can directly set the parameters of the estimators contained in
        `transformers` of `ColumnTransformer`.

        Parameters
        ----------
        **kwargs : dict
            Estimator parameters.

        Returns
        -------
        self : ColumnTransformer
            This estimator.
        rZ   )rZ   )_set_params)rJ   kwargss     rK   
set_paramszColumnTransformer.set_params  s"    " 	33F333rM   c              #     K   |r| j         }nGd t          | j        | j                  D             }| j        d         rt          || j        g          }t          d|          }| j        pi j        }|D ]l\  }}}	|r|dk    r|rt          |	          r!|r8t          j        |	          }
| j        |         }| j        |         }	|
r|	d         }	|||	 ||          fV  mdS )a%  
        Generate (name, trans, columns, weight) tuples.


        Parameters
        ----------
        fitted : bool
            If True, use the fitted transformers (``self.transformers_``) to
            iterate through transformers, else use the transformers passed by
            the user (``self.transformers``).

        column_as_labels : bool
            If True, columns are returned as string labels. If False, columns
            are returned as they were given by the user. This can only be True
            if the ``ColumnTransformer`` is already fitted.

        skip_drop : bool
            If True, 'drop' transformers are filtered out.

        skip_empty_columns : bool
            If True, transformers with empty selected columns are filtered out.

        Yields
        ------
        A generator of tuples containing:
            - name : the name of the transformer
            - transformer : the transformer object
            - columns : the columns for that transformer
            - weight : the weight of the transformer
        c                 &    g | ]\  \  }}}}|||fS rP   rP   )rR   rS   rT   rU   columns        rK   rV   z+ColumnTransformer._iter.<locals>.<listcomp>  s:       ,$T5!f uf%  rM   r
   Fr4   r   N)rf   r^   r?   _columns
_remainderr   "_with_dtype_warning_enabled_set_torC   get_is_empty_column_selectionnpisscalar_transformer_to_input_indicesfeature_names_in_)rJ   fittedcolumn_as_labels	skip_dropskip_empty_columnsr?   
get_weightrS   rT   columnscolumns_is_scalarindicess               rK   _iterzColumnTransformer._iter  sB     >  
	F-LL 03D4Et}0U0U  L
 q! F$\DO3DEE :%NN.4"9
$0 	; 	; D% Uf__! &@&I&I  	)$&K$8$8!<TB09$ )%ajGD)9)9:::::#	; 	;rM   c           	          | j         sdS t          | j          \  }}}|                     |           |D ]Z}|dv rt          |d          st          |d          rt          |d          s#t	          d|dt          |          d          [dS )	zValidate names of transformers and the transformers themselves.

        This checks whether given transformers have the required methods, i.e.
        `fit` or `fit_transform` and `transform` implemented.
        N)r4   r5   r6   r8   r7   zbAll estimators should implement fit and transform, or can be 'drop' or 'passthrough' specifiers. 'z' (type z
) doesn't.)r?   r^   _validate_nameshasattrrW   type)rJ   namesr?   rU   ts        rK   _validate_transformersz(ColumnTransformer._validate_transformers  s       	F!$d&7!8|Q 	U###  	 	A+++Au%% O)D)D W;N N   i >?QQQI  		 	rM   c                     g }i }| j         D ]H\  }}}t          |          r ||          }|                    |           t          ||          ||<   I|| _        || _        dS )a7  
        Converts callable column specifications.

        This stores a dictionary of the form `{step_name: column_indices}` and
        calls the `columns` on `X` if `columns` is a callable for a given
        transformer.

        The results are then stored in `self._transformer_to_input_indices`.
        N)r?   callableappendr   rv   r}   )rJ   Xall_columnstransformer_to_input_indicesrS   rU   r   s          rK   _validate_column_callablesz,ColumnTransformer._validate_column_callables  s     ')$ $ 1 	Q 	QD!W   %!'!**w'''1DQ1P1P(..#-I***rM   c                    t          t          | j                                                   }t	          t          t          | j                            |z
            }|| j        d<   |                     |          }d| j        |f| _	        dS )zm
        Validates ``remainder`` and defines ``_remainder`` targeting
        the remaining columns.
        r@   N)
setr   r}   valuessortedrangen_features_in__get_remainder_colsr@   rw   )rJ   r   cols	remainingremainder_colss        rK   _validate_remainderz%ColumnTransformer._validate_remainder-  s~    
 5$<CCEEFGG3uT%899::TABB	:C*;711)<<&GrM   c                     	 d | j         D             }t          |          dk    rt          t          |                    S n# t          $ r Y dS w xY wdS )Nc                 2    h | ]^ }}t          |          S rP   )r   )rR   rU   cs      rK   	<setcomp>z>ColumnTransformer._get_remainder_cols_dtype.<locals>.<setcomp>:  s%    RRRWq!-a00RRRrM   r9   int)r?   lennextiterrX   )rJ   
all_dtypess     rK   _get_remainder_cols_dtypez+ColumnTransformer._get_remainder_cols_dtype8  st    	RR@QRRRJ:!##D,,--- $ 	 	 	 55	 us   ?A 
AAc                     |                                  }| j        r|dk    rt          |          S |dk    rt          | j                           S |dk    r fdt          | j                  D             S S )Nr   )future_dtypestrboolc                     g | ]}|v S rP   rP   )rR   ir   s     rK   rV   z9ColumnTransformer._get_remainder_cols.<locals>.<listcomp>J  s    EEEQALEEErM   )r   rE   _RemainderColsListlistr~   r   r   )rJ   r   dtypes    ` rK   r   z%ColumnTransformer._get_remainder_colsC  s    ..00( 	CUe^^%gEBBBBE>>.w7888F??EEEE%0C*D*DEEEErM   c                 8    t          di d | j        D             S )zAccess the fitted transformer by name.

        Read-only attribute to access any transformer by given name.
        Keys are transformer names and values are the fitted transformer
        objects.
        c                     i | ]	\  }}}||
S rP   rP   rQ   s       rK   
<dictcomp>z9ColumnTransformer.named_transformers_.<locals>.<dictcomp>V  s     MMMeQeMMMrM   rP   )r   rf   rY   s    rK   named_transformers_z%ColumnTransformer.named_transformers_M  s*     NNMM$:LMMMNNNrM   c                     | j         |         }||         }t          |d          s(t          d| dt          |          j         d          |                    |          S )zGets feature names of transformer.

        Used in conjunction with self._iter(fitted=True) in get_feature_names_out.
        get_feature_names_outTransformer z (type z)) does not provide get_feature_names_out.)r}   r   AttributeErrorr   __name__r   )rJ   rS   rT   feature_names_incolumn_indicesr   s         rK   %_get_feature_name_out_for_transformerz7ColumnTransformer._get_feature_name_out_for_transformerX  s    
 ;DA 0u566 	 5t 5 5DKK,@ 5 5 5   **5111rM   c                 H   t          |            t          | |          }g }|                     dddd          D ]6^}}}|                     |||          }||                    ||f           7|st          j        g t                    S |                     |          S )a  Get output feature names for transformation.

        Parameters
        ----------
        input_features : array-like of str or None, default=None
            Input features.

            - If `input_features` is `None`, then `feature_names_in_` is
              used as feature names in. If `feature_names_in_` is not defined,
              then the following input feature names are generated:
              `["x0", "x1", ..., "x(n_features_in_ - 1)"]`.
            - If `input_features` is an array-like, then `input_features` must
              match `feature_names_in_` if `feature_names_in_` is defined.

        Returns
        -------
        feature_names_out : ndarray of str objects
            Transformed feature names.
        TF)r   r   r   r   Nr   )	r/   r)   r   r   r   r{   arrayobject!_add_prefix_for_feature_names_out)rJ   input_features"transformer_with_feature_names_outrS   rT   rU   feature_names_outs          rK   r   z'ColumnTransformer.get_feature_names_outg  s    ( 	0~FF .0*#zz"#	  *  
  
 	Q 	QOD%! !% J Je^! ! !(.55t=N6OPPPP1 	.8Bf----55.
 
 	
rM   c                 *   dt          | j                  r| j        nUt          | j        t                    rt	          t
          | j                  n| j        du rt	          t
          d          Ht          t          j        fd|D                                 }t          j
        |t                    S t          t          j        d |D                                 }d |                    d	          D             }|                                 |rXt          |          d	k    r#t          |dd
                   dd         dz   }nt          |          }t!          d| d          t          j        d |D                       S )a  Add prefix for feature names out that includes the transformer names.

        Parameters
        ----------
        transformer_with_feature_names_out : list of tuples of (str, array-like of str)
            The tuple consistent of the transformer's name and its feature names out.

        Returns
        -------
        feature_names_out : ndarray of shape (n_features,), dtype=str
            Transformed feature names.
        N)
str_formatTz"{transformer_name}__{feature_name}c              3   >   K   | ]\  }fd |D             V  dS )c              3   0   K   | ]} |          V  d S rI   rP   )rR   r   feature_names_out_callablerS   s     rK   re   zPColumnTransformer._add_prefix_for_feature_names_out.<locals>.<genexpr>.<genexpr>  s1      TTQ//a88TTTTTTrM   NrP   )rR   r   rS   r   s     @rK   re   zFColumnTransformer._add_prefix_for_feature_names_out.<locals>.<genexpr>  sV       $ $// UTTTTBSTTT$ $ $ $ $ $rM   r   c              3       K   | ]	\  }}|V  
d S rI   rP   )rR   rU   ss      rK   re   zFColumnTransformer._add_prefix_for_feature_names_out.<locals>.<genexpr>  s&      QQdaQQQQQQrM   c                 $    g | ]\  }}|d k    |S )r9   rP   rR   rS   counts      rK   rV   zGColumnTransformer._add_prefix_for_feature_names_out.<locals>.<listcomp>  s)     
 
 
 T5%RS))D)))rM         z, ...]zOutput feature names: z[ are not unique. Please set verbose_feature_names_out=True to add prefixes to feature namesc                     g | ]\  }}|S rP   rP   )rR   rU   rS   s      rK   rV   zGColumnTransformer._add_prefix_for_feature_names_out.<locals>.<listcomp>  s    DDDgaTDDDrM   )r   rD   
isinstancer   r   "_feature_names_out_with_str_formatr   r   from_iterabler{   asarrayr   r   most_commonsortr   rX   concatenate)rJ   r   r   feature_names_counttop_6_overlap
names_reprr   s         @rK   r   z3ColumnTransformer._add_prefix_for_feature_names_out  s    &*"D233 	)-)G&&6<< 		)029* * *&& +t33)02?* * *&
 &1# $ $ $ $3U$ $ $   E :e62222 &QQ.PQQQQQ
 

 
$7$C$CA$F$F
 
 
 	 
	=!!Q&& !rr!233CRC88C

 //
R R R R  
 ~DD!CDDD
 
 	
rM   c                 :   t          |          }g }|                     dddd          D ]I\  }}}}|dk    rd}n!t          |          r|}nt          |          }|                    |||f           Jt          |          rJ t          d|          | _        dS )a  Set self.transformers_ from given transformers.

        Parameters
        ----------
        transformers : list of estimators
            The fitted estimators as the output of
            `self._call_func_on_transformers(func=_fit_transform_one, ...)`.
            That function doesn't include 'drop' or transformers for which no
            column is selected. 'drop' is kept as is, and for the no-column
            transformers the unfitted transformer is put in
            `self.transformers_`.
        Fr   r   r   r   r4   TN)r   r   rz   r   r   r   rx   rf   )	rJ   r?   fitted_transformersrf   rS   oldru   rU   rT   s	            rK   _update_fitted_transformersz-ColumnTransformer._update_fitted_transformers  s     #<00$(JJ"$	 %/ %
 %
 	8 	8 D#vq f}}+F33 2011  $v!67777 +,,,,,?mTTrM   c                    d |                      dddd          D             }t          ||          D ]L\  }}t          |dd          dk    s2t          |d          s"t	          d	                    |                    Mt          d
|           d         dk    rdS 	 ddl}n# t          $ r Y dS w xY wt          ||          D ]\  }}t          |          s|j
                                                                        D ]]\  }}t          |dd          |j        ur|j        ||         j        vr3| j        j        }t	          d| d| d| d| d| d          dS )z
        Ensure that the output of each transformer is 2D. Otherwise
        hstack can raise an error or produce incorrect results.
        c                     g | ]	\  }}}}|
S rP   rP   )rR   rS   rU   s      rK   rV   z6ColumnTransformer._validate_output.<locals>.<listcomp>  s0     
 
 
aA 
 
 
rM   TFr   ndimr   r
   __dataframe__z^The output of the '{0}' transformer should be 2D (numpy array, scipy sparse array, dataframe).r7   densepandasNna_valuezThe output of the 'z' transformer for column 'z' has dtype z and uses pandas.NA to represent null values. Storing this output in a numpy array can cause errors in downstream scikit-learn estimators, and inefficiencies. To avoid this problem you can (i) store the output in a pandas DataFrame by using zF.set_output(transform='pandas') or (ii) modify the input data or the 'z`' transformer to avoid the presence of pandas.NA (for example by using pandas.DataFrame.astype).)r   r^   ri   r   rX   formatr   r   ImportErrorr,   dtypesto_dictitemsNAr   rj   r   )	rJ   resultr   XsrS   pdcol_namer   
class_names	            rK   _validate_outputz"ColumnTransformer._validate_output  s   

 
!%!&#'	 ", " "
 
 
 FE** 	 	HB2vq))Q..wr?7S7S. 66<fTll   k4009XEEF	 	 	 	FF	FE** 	 	HB $$ #%9#4#4#6#6#<#<#>#>  %5*d3325@@58 333!^4
 	1$ 	1 	1!	1 	1/4	1 	1 #	1 	1 04	1 	1 	1  	 	s   B# #
B10B1c                 V   d}i | _         t          |                     dddd                    D ]=\  }\  }}}}||         j        d         }t	          |||z             | j         |<   ||z  }>d | j        D             dgz   }|D ]#}|| j         vrt	          dd          | j         |<   $dS )	zA
        Record which transformer produced which column.
        r   TFr   r9   c                     g | ]
}|d          S r   rP   rR   r   s     rK   rV   z<ColumnTransformer._record_output_indices.<locals>.<listcomp><  s    555aQqT555rM   r@   N)output_indices_	enumerater   shapeslicer?   )rJ   r   idxtransformer_idxrS   rU   	n_columns	all_namess           rK   _record_output_indicesz(ColumnTransformer._record_output_indices&  s     !09JJ!&#'	   1
 1
 
	 
	,O_dAq! ?+1!4I).sC)O)D)DD &9CC
 654#4555E	 	9 	9D4///-21a[[$T*	9 	9rM   c                 $    | j         sd S d|||fz  S )Nz(%d of %d) Processing %s)r<   )rJ   rS   r   totals       rK   _log_messagezColumnTransformer._log_messageA  s#    | 	4)S%,>>>rM   c                    |t           u rd}nd}t          |                     ||dd                    }	 g }t          |d          D ]\  }	\  }
}}}|t           u rv|dk    r<t	          d|           }t          ddd	                              |d
                   }t          d|                     |
|	t          |                              }ni }|
                     t          |          d|st          |          n|t          ||d          ||d|d||
         i            t          | j                  |          S # t           $ r,}dt#          |          v rt!          t$                    | d}~ww xY w)a  
        Private function to fit and/or transform on demand.

        Parameters
        ----------
        X : {array-like, dataframe} of shape (n_samples, n_features)
            The data to be used in fit and/or transform.

        y : array-like of shape (n_samples,)
            Targets.

        func : callable
            Function to call, which can be _fit_transform_one or
            _transform_one.

        column_as_labels : bool
            Used to iterate through transformers. If True, columns are returned
            as strings. If False, columns are returned as they were given by
            the user. Can be True only if the ``ColumnTransformer`` is already
            fitted.

        routed_params : dict
            The routed parameters as the output from ``process_routing``.

        Returns
        -------
        Return value (transformers and/or transformed X data) depends
        on the passed function.
        FTr   r9   )startr5   r7   z
one-to-one)accept_sparsecheck_inverser   r   r`   r0   )message_clsnamemessage)axis)transformerr   yweightparams)rB   z'Expected 2D array, got 1D array insteadNrP   )r   r   r   r   r   r   rh   dictr  r   r   r'   r   r   r&   rB   rX   r   _ERR_MSG_1DCOLUMN)rJ   r   r  funcr   routed_paramsr   r?   jobsr   rS   rT   r   r  output_config
extra_argses                    rK   _call_func_on_transformersz,ColumnTransformer._call_func_on_transformersF  s   < %%%FFFJJ!1#'	   
 
#	D7@UV7W7W7W  33dE7F-----(:;(M(M 3*.*/.:! ! ! %*}W/E*FF	  "&(; $ 1 1$S=N=N O O" " "JJ
 "$J!GDMM 8>$IE%LLLE(G!<<<%	 
 %   -T2  	 	 	 	 084;///555 	 	 	8CFFBB !233:		s   DE 
F'E<<Fc                 H    t          || d            | j        |fd|i| | S )a  Fit all transformers using X.

        Parameters
        ----------
        X : {array-like, dataframe} of shape (n_samples, n_features)
            Input data, of which specified subsets are used to fit the
            transformers.

        y : array-like of shape (n_samples,...), default=None
            Targets for supervised learning.

        **params : dict, default=None
            Parameters to be passed to the underlying transformers' ``fit`` and
            ``transform`` methods.

            You can only pass this if metadata routing is enabled, which you
            can enable using ``sklearn.set_config(enable_metadata_routing=True)``.

            .. versionadded:: 1.4

        Returns
        -------
        self : ColumnTransformer
            This estimator.
        r6   r  )r"   r8   )rJ   r   r  r  s       rK   r6   zColumnTransformer.fit  s=    4 	&$... 	1,,,V,,,rM   )prefer_skip_nested_validationc                    t          || d           t          | |d           t          |          }t          | |d           |                                  t          |          }|                     |           |                     |           t                      rt          | dfi |}n| 
                                }|                     ||t          d|          }|s+|                     g            t          j        |df          S t!          | \  }}t#          d |D                       rHt%          d |D                       }	t%          d	 |D                       }
|	|
z  }|| j        k     | _        nd| _        |                     |           |                     |           |                     |           |                     t1          |          |
          S )ac  Fit all transformers, transform the data and concatenate results.

        Parameters
        ----------
        X : {array-like, dataframe} of shape (n_samples, n_features)
            Input data, of which specified subsets are used to fit the
            transformers.

        y : array-like of shape (n_samples,), default=None
            Targets for supervised learning.

        **params : dict, default=None
            Parameters to be passed to the underlying transformers' ``fit`` and
            ``transform`` methods.

            You can only pass this if metadata routing is enabled, which you
            can enable using ``sklearn.set_config(enable_metadata_routing=True)``.

            .. versionadded:: 1.4

        Returns
        -------
        X_t : {array-like, sparse matrix} of                 shape (n_samples, sum_n_components)
            Horizontally stacked results of transformers. sum_n_components is the
            sum of n_components (output dimension) over transformers. If
            any result is a sparse matrix, everything will be converted to
            sparse matrices.
        r8   TresetFr   r  r   c              3   >   K   | ]}t          j        |          V  d S rI   )r	   issparserR   r   s     rK   re   z2ColumnTransformer.fit_transform.<locals>.<genexpr>  s,      ..avq!!......rM   c              3   Z   K   | ]&}t          j        |          r|j        n|j        V  'd S rI   )r	   r#  nnzsizer$  s     rK   re   z2ColumnTransformer.fit_transform.<locals>.<genexpr>  s9      JJ!vq11=aeeqvJJJJJJrM   c              3      K   | ]:}t          j        |          r|j        d          |j        d         z  n|j        V  ;dS )r   r9   N)r	   r#  r   r'  r$  s     rK   re   z2ColumnTransformer.fit_transform.<locals>.<genexpr>  sZ        NO6?1+=+=I
QWQZ''16     rM   	n_samples)r"   r(   _check_Xr*   r   r-   r   r   r#   r$   _get_empty_routingr  r   r   r{   zerosr^   anysumrA   sparse_output_r   r  _hstackr   )rJ   r   r  r  r*  r  r   r   r?   r&  r  densitys               rK   r8   zColumnTransformer.fit_transform  s   D 	&$888T1D1111QKK$....##%%% OO	''***  ### 	6+D/LLVLLMM 3355M00"' 1 
 
  	,,,R0008YN+++<L ..2..... 	(JJrJJJJJC  SU    E EkG")D,A"AD"'D((666b!!!##B'''||DHH	|:::rM   c                 p    t          | d           t                      t          |          }t           d          ot	          |          pt          |d          }t          |          }t          |          }|r j        fd j        	                                D             }t          t          |           }t           fd|D                       }|t          |          z
  }	|	rt          d|	           nt           |d           t                      rt           dfi |}
n                                 }
                     |d	t$          ||

          }                     |           |st)          j        |df          S                      t/          |          |          S )a  Transform X separately by each transformer, concatenate results.

        Parameters
        ----------
        X : {array-like, dataframe} of shape (n_samples, n_features)
            The data to be transformed by subset.

        **params : dict, default=None
            Parameters to be passed to the underlying transformers' ``transform``
            method.

            You can only pass this if metadata routing is enabled, which you
            can enable using ``sklearn.set_config(enable_metadata_routing=True)``.

            .. versionadded:: 1.4

        Returns
        -------
        X_t : {array-like, sparse matrix} of                 shape (n_samples, sum_n_components)
            Horizontally stacked results of transformers. sum_n_components is the
            sum of n_components (output dimension) over transformers. If
            any result is a sparse matrix, everything will be converted to
            sparse matrices.
        r7   r~   r   c                 :    g | ]\  }}|v 	|         d k    |S )r4   rP   )rR   rS   indnamed_transformerss      rK   rV   z/ColumnTransformer.transform.<locals>.<listcomp>7  sC     # # #D#---2DT2Jf2T2T 2T2T2TrM   c              3   2   K   | ]}j         |         V  d S rI   )r~   )rR   r5  rJ   s     rK   re   z.ColumnTransformer.transform.<locals>.<genexpr>>  s+      OOCD237OOOOOOrM   zcolumns are missing: Fr  Nr!  r   r)  )r"   r/   r+  r   r,   r-   r+   r   r}   r   r   r   rX   r*   r#   r$   r,  r  r   r   r{   r-  r1  r   )rJ   r   r  %fit_dataframe_and_transform_dataframer*  column_namesnon_dropped_indicesall_indicesr  diffr  r   r6  s   `           @rK   r7   zColumnTransformer.transform	  s   4 	&$444QKK 18>Q0R0R 1
!;? ; ; 	. !OO	)!,,0 	4!%!9# # # #!%!C!I!I!K!K# # # e%89::KOOOO;OOOOOIs<000D A !?!?!?@@@A
 dAU3333 	6+D+HHHHMM 3355M,,B' - 
 
 	b!!! 	,8YN+++||DHH	|:::rM   c                v   | j         rV	 d |D             }n"# t          $ r}t          d          |d}~ww xY wt          j        |                                          S d |D             }t          d|           r)t          fd|D                       rd |                     dd	dd
          D             }d |D             }| j        r2| 	                    t          t          ||                              }nt          t          j        |                    }t          |          }t          d |                                D                       rt#          d |                                D                       }d| d}	t          ||          D ]f\  }
}|j        d         dk    rt#          t)          |j                                      |                    }t/          |          r|	d|
 d| dz  }	gt          |	dz             d}|D ]R}|j        d         dk    r||||j        d         z            }                    ||           ||j        d         z  }S                    |          }|j        d         }||k    rt          d          |S t3          j        |          S )a  Stacks Xs horizontally.

        This allows subclasses to control the stacking behavior, while reusing
        everything else from ColumnTransformer.

        Parameters
        ----------
        Xs : list of {array-like, sparse matrix, dataframe}
            The container to concatenate.
        n_samples : int
            The number of samples in the input data to checking the transformation
            consistency.
        c                 2    g | ]}t          |d d          S )TF)r
  ensure_all_finite)r.   r$  s     rK   rV   z-ColumnTransformer._hstack.<locals>.<listcomp>o  s7            OOO     rM   zQFor a sparse output, all columns should be a numeric or convertible to a numeric.Nc                 b    g | ],}t          j        |          r|                                n|-S rP   )r	   r#  toarray)rR   fs     rK   rV   z-ColumnTransformer._hstack.<locals>.<listcomp>{  s3    GGGq!3!3:!))+++GGGrM   r7   c              3   B   K   | ]}                     |          V  d S rI   )is_supported_container)rR   r   adapters     rK   re   z,ColumnTransformer._hstack.<locals>.<genexpr>}  s1      MMQw==a@@MMMMMMrM   c                     g | ]
}|d          S r   rP   r   s     rK   rV   z-ColumnTransformer._hstack.<locals>.<listcomp>  s,     % % % aD% % %rM   TFr   c                 >    g | ]}|j         d          dk    |j        S )r9   r   )r   r   r$  s     rK   rV   z-ColumnTransformer._hstack.<locals>.<listcomp>  s%    %O%O%OAqwqzQairM   c              3   "   K   | ]
}|d k    V  dS r9   NrP   )rR   r   s     rK   re   z,ColumnTransformer._hstack.<locals>.<genexpr>  s&      OO519OOOOOOrM   c              3   ,   K   | ]\  }}|d k    |V  dS rI  rP   r   s      rK   re   z,ColumnTransformer._hstack.<locals>.<genexpr>  s8       : : +e$qyy !(yyy: :rM   zUDuplicated feature names found before concatenating the outputs of the transformers: z.
r9   r   r   z  has conflicting columns names: zEither make sure that the transformers named above do not generate columns with conflicting names or set verbose_feature_names_out=True to automatically prefix to the output feature names with the name of the transformer to prevent any conflicting names.a   Concatenating DataFrames from the transformer's output lead to an inconsistent number of samples. The output may have Pandas Indexes that do not match, or that transformers are returning number of samples which are not the same as the number input samples.)r0  rX   r	   hstacktocsrr   allr   rD   r   r   r^   r   r   r   r.  r   r   r   r   r   r   intersectionr   rename_columnsr{   )rJ   r   r*  converted_Xsr  transformer_namesfeature_names_outsr   duplicated_feature_nameserr_msgtransformer_namer   dup_cols_in_transformer	names_idx	names_outoutputoutput_samplesrE  s                    @rK   r1  zColumnTransformer._hstack\  s     _	!             @   =..44666GGBGGGB,[$??G J3MMMM"MMMMM J% %!ZZ#)."&+/	 (  % % %! &P%O%O%O%O"1 ( *.)O)OS!24FGGHH* *&&
 *.e.ABT.U.U)V)V&*12D*E*E'OO2E2L2L2N2NOOOOO 39 : :/B/H/H/J/J: : : 4 40> 8> > >  
 477H"3M3M 
" 
"/,a wqzQ (6< #AI ; ;<T U U7 73  ##:;; " '%S3C %S %S6M%S %S %S!" )#%%   	 , ,AwqzQ  29y17ST:?U3U VI**1i888+II ++!'a!Y..$$   9R== s    
616c                    t          | j        t                    r| j        dk    r| j        }nt	          | d          rv| j        d         }t	          | d          r:|r8t          d |D                       s| j        |                                         }t          | j        d| j        |fg          }nt          | j        d| j        dfg          }t          | \  }}}t          d|||	          S )
Nr4   rw   r
   r~   c              3   @   K   | ]}t          |t                    V  d S rI   )r   r   rR   r]   s     rK   re   z6ColumnTransformer._sk_visual_block_.<locals>.<genexpr>  s,      NNSJsC00NNNNNNrM   r@    parallel)r   name_details)r   r@   r   r?   r   rw   rM  r~   tolistr   r^   r   )rJ   r?   remainder_columnsr   r`  s        rK   _sk_visual_block_z#ColumnTransformer._sk_visual_block_  s"   dnc** 	Yt~/G/G,LLT<(( 	Y $ 2122W%W NN<MNNNNNW
 %)$:;L$M$T$T$V$V! ![$.BS$T#U LL !!2k4>SU5V4WXXL,/,>)|\E
 
 
 	
rM   c                     	 | j         |         S # t          $ r}t          d          |d }~wt          $ r}t          d| d          |d }~ww xY w)Nz5ColumnTransformer is subscriptable after it is fitted'z!' is not a valid transformer name)r   r   rW   KeyError)rJ   keyr  s      rK   __getitem__zColumnTransformer.__getitem__  s    	N+C00 	 	 	G   	N 	N 	NEsEEEFFAM	Ns    
A)AA

Ac                 \    t          di d |                     dddd          D             S )zReturn empty routing.

        Used while routing can be disabled.

        TODO: Remove when ``set_config(enable_metadata_routing=False)`` is no
        more an option.
        c           	      P    i | ]#\  }}}}|t          di d  t          D             $S )c                     i | ]}|i S rP   rP   )rR   methods     rK   r   zCColumnTransformer._get_empty_routing.<locals>.<dictcomp>.<dictcomp>  s    @@@fvr@@@rM   rP   )r   r   )rR   rS   steprU   s       rK   r   z8ColumnTransformer._get_empty_routing.<locals>.<dictcomp>  sO       $D$1 eAA@@@@@AA  rM   FTr   rP   )r   r   rY   s    rK   r,  z$ColumnTransformer._get_empty_routing  s[      

 

 (,

 %*"'+	 )3 ) )  

 

 
	
rM   c                    t          | j        j                  }t          | j        d| j        dfg          }|D ]\  }}}t                      }t          |d          r-|                    dd                              dd           nV|                    dd                              dd                              dd                              dd           |                    dd            |j        d	d|i||i |S )
aj  Get metadata routing of this object.

        Please check :ref:`User Guide <metadata_routing>` on how the routing
        mechanism works.

        .. versionadded:: 1.4

        Returns
        -------
        routing : MetadataRouter
            A :class:`~sklearn.utils.metadata_routing.MetadataRouter` encapsulating
            routing information.
        )ownerr@   Nr8   r6   )callercalleer7   method_mappingrP   )	r    rj   r   r   r?   r@   r!   r   add)rJ   routerr?   rS   rm  rU   rr  s          rK   get_metadata_routingz&ColumnTransformer.get_metadata_routing  s6     dn&=>>>
 T.+t~t1T0UVV) 	F 	FMD$*__Nt_-- "&&eO&LLPP. Q     #&&eE&BBSkS::SS>>SSDDDk+FFFFJEEnEtEEEErM   c                     t                                                      }	 t          d | j        D                       |j        _        n# t          $ r Y nw xY w|S )Nc              3   X   K   | ]%\  }}}|d v
t          |          j        j        V  &dS rc   )r   
input_tagsr	   rQ   s       rK   re   z5ColumnTransformer.__sklearn_tags__.<locals>.<genexpr>*  sL       ) )"D% 777 *17777) )rM   )rg   __sklearn_tags__rM  r?   rx  r	   	Exception)rJ   tagsrj   s     rK   ry  z"ColumnTransformer.__sklearn_tags__'  s~    ww''))
	%( ) )&*&7) ) ) & &DO""
  	 	 	 D		
 s   (A 
AA)TrI   )2r   
__module____qualname____doc__r   r   tupler   r   r   r   r   r  r   r   rF   __annotations__rL   propertyrZ   setterrh   rn   rr   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r6   r   r8   r7   r1  rc  rh  r,  ru  ry  __classcell__rj   s   @rK   r0   r0   ?   sl        a aH vve}}-J.//J{+,,J566

 &XdAq@@@AT" $d|;&/h%?%.K$ $D   &  "&!%A A A A A* % % X% 
& 
& 
& '+ ' ' ' ' ' ' 'R< < < <(  (E; E; E;N  8J J J*	H 	H 	H	 	 	   O O XO2 2 2,
 ,
 ,
 ,
\<
 <
 <
|!U !U !UF. . .`9 9 96? ? ?
N N N`   @ \&+  M; M; M;	 M;^Q; Q; Q;fm! m! m!^
 
 
,N N N
 
 
(& & &P        rM   r0   c                     t          | d          rt          | d          s$t          | d          st          j        |           r| S t          | dt                    S )zMUse check_array only when necessary, e.g. on lists and other non-array-likes.	__array__r   r   z	allow-nan)r?  r   )r   r	   r#  r.   r   )r   s    rK   r+  r+  7  sj     
K	 	 %,Q%8%81o&& ?1
 qKvFFFFrM   c                 0   t          | d          r9t          j        | j        t          j                  r|                                  S t          | d          r<t          |           dk    p(t          d | D                       ot          |            S dS )zd
    Return True if the column selection is empty (empty list or all-False
    boolean array).

    r   __len__r   c              3   @   K   | ]}t          |t                    V  d S rI   )r   r   r]  s     rK   re   z-_is_empty_column_selection.<locals>.<genexpr>M  s,      ;;S:c4((;;;;;;rM   F)r   r{   
issubdtyper   bool_r.  r   rM  )ru   s    rK   rz   rz   B  s     vw 	BM&,$I$I 	::<<		#	# KK1  ;;F;;;;;  KK	
 urM   c                     t          |  \  }}t          t          |           \  }}t          t          |||                    }|S )z;
    Construct (name, trans, column) tuples from list

    )r^   r   r   )
estimatorsr?   r   r   rU   transformer_lists         rK   _get_transformer_listr  T  sJ    
  ,L'$\223HE1C|W==>>rM   r4   rG   FT)r@   rA   rB   r<   rD   rE   c           	      L    t          |          }t          ||| ||||          S )a`  Construct a ColumnTransformer from the given transformers.

    This is a shorthand for the ColumnTransformer constructor; it does not
    require, and does not permit, naming the transformers. Instead, they will
    be given names automatically based on their types. It also does not allow
    weighting with ``transformer_weights``.

    Read more in the :ref:`User Guide <make_column_transformer>`.

    Parameters
    ----------
    *transformers : tuples
        Tuples of the form (transformer, columns) specifying the
        transformer objects to be applied to subsets of the data.

        transformer : {'drop', 'passthrough'} or estimator
            Estimator must support :term:`fit` and :term:`transform`.
            Special-cased strings 'drop' and 'passthrough' are accepted as
            well, to indicate to drop the columns or to pass them through
            untransformed, respectively.
        columns : str,  array-like of str, int, array-like of int, slice,                 array-like of bool or callable
            Indexes the data on its second axis. Integers are interpreted as
            positional columns, while strings can reference DataFrame columns
            by name. A scalar string or int should be used where
            ``transformer`` expects X to be a 1d array-like (vector),
            otherwise a 2d array will be passed to the transformer.
            A callable is passed the input data `X` and can return any of the
            above. To select multiple columns by name or dtype, you can use
            :obj:`make_column_selector`.

    remainder : {'drop', 'passthrough'} or estimator, default='drop'
        By default, only the specified columns in `transformers` are
        transformed and combined in the output, and the non-specified
        columns are dropped. (default of ``'drop'``).
        By specifying ``remainder='passthrough'``, all remaining columns that
        were not specified in `transformers` will be automatically passed
        through. This subset of columns is concatenated with the output of
        the transformers.
        By setting ``remainder`` to be an estimator, the remaining
        non-specified columns will use the ``remainder`` estimator. The
        estimator must support :term:`fit` and :term:`transform`.

    sparse_threshold : float, default=0.3
        If the transformed output consists of a mix of sparse and dense data,
        it will be stacked as a sparse matrix if the density is lower than this
        value. Use ``sparse_threshold=0`` to always return dense.
        When the transformed output consists of all sparse or all dense data,
        the stacked result will be sparse or dense, respectively, and this
        keyword will be ignored.

    n_jobs : int, default=None
        Number of jobs to run in parallel.
        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
        for more details.

    verbose : bool, default=False
        If True, the time elapsed while fitting each transformer will be
        printed as it is completed.

    verbose_feature_names_out : bool, default=True
        If True, :meth:`ColumnTransformer.get_feature_names_out` will prefix
        all feature names with the name of the transformer that generated that
        feature.
        If False, :meth:`ColumnTransformer.get_feature_names_out` will not
        prefix any feature names and will error if feature names are not
        unique.

        .. versionadded:: 1.0

    force_int_remainder_cols : bool, default=True
        Force the columns of the last entry of `transformers_`, which
        corresponds to the "remainder" transformer, to always be stored as
        indices (int) rather than column names (str). See description of the
        :attr:`ColumnTransformer.transformers_` attribute for details.

        .. note::
            If you do not access the list of columns for the remainder columns
            in the :attr:`ColumnTransformer.transformers_` fitted attribute,
            you do not need to set this parameter.

        .. versionadded:: 1.5

        .. versionchanged:: 1.7
           The default value for `force_int_remainder_cols` will change from
           `True` to `False` in version 1.7.

    Returns
    -------
    ct : ColumnTransformer
        Returns a :class:`ColumnTransformer` object.

    See Also
    --------
    ColumnTransformer : Class that allows combining the
        outputs of multiple transformer objects used on column subsets
        of the data into a single feature space.

    Examples
    --------
    >>> from sklearn.preprocessing import StandardScaler, OneHotEncoder
    >>> from sklearn.compose import make_column_transformer
    >>> make_column_transformer(
    ...     (StandardScaler(), ['numerical_column']),
    ...     (OneHotEncoder(), ['categorical_column']))
    ColumnTransformer(transformers=[('standardscaler', StandardScaler(...),
                                     ['numerical_column']),
                                    ('onehotencoder', OneHotEncoder(...),
                                     ['categorical_column'])])
    )rB   r@   rA   r<   rD   rE   )r  r0   )r@   rA   rB   r<   rD   rE   r?   r  s           rK   r1   r1   b  s?    t -\::)";!9   rM   c                   (    e Zd ZdZdddddZd ZdS )r2   a	  Create a callable to select columns to be used with
    :class:`ColumnTransformer`.

    :func:`make_column_selector` can select columns based on datatype or the
    columns name with a regex. When using multiple selection criteria, **all**
    criteria must match for a column to be selected.

    For an example of how to use :func:`make_column_selector` within a
    :class:`ColumnTransformer` to select columns based on data type (i.e.
    `dtype`), refer to
    :ref:`sphx_glr_auto_examples_compose_plot_column_transformer_mixed_types.py`.

    Parameters
    ----------
    pattern : str, default=None
        Name of columns containing this regex pattern will be included. If
        None, column selection will not be selected based on pattern.

    dtype_include : column dtype or list of column dtypes, default=None
        A selection of dtypes to include. For more details, see
        :meth:`pandas.DataFrame.select_dtypes`.

    dtype_exclude : column dtype or list of column dtypes, default=None
        A selection of dtypes to exclude. For more details, see
        :meth:`pandas.DataFrame.select_dtypes`.

    Returns
    -------
    selector : callable
        Callable for column selection to be used by a
        :class:`ColumnTransformer`.

    See Also
    --------
    ColumnTransformer : Class that allows combining the
        outputs of multiple transformer objects used on column subsets
        of the data into a single feature space.

    Examples
    --------
    >>> from sklearn.preprocessing import StandardScaler, OneHotEncoder
    >>> from sklearn.compose import make_column_transformer
    >>> from sklearn.compose import make_column_selector
    >>> import numpy as np
    >>> import pandas as pd  # doctest: +SKIP
    >>> X = pd.DataFrame({'city': ['London', 'London', 'Paris', 'Sallisaw'],
    ...                   'rating': [5, 3, 4, 5]})  # doctest: +SKIP
    >>> ct = make_column_transformer(
    ...       (StandardScaler(),
    ...        make_column_selector(dtype_include=np.number)),  # rating
    ...       (OneHotEncoder(),
    ...        make_column_selector(dtype_include=object)))  # city
    >>> ct.fit_transform(X)  # doctest: +SKIP
    array([[ 0.90453403,  1.        ,  0.        ,  0.        ],
           [-1.50755672,  1.        ,  0.        ,  0.        ],
           [-0.30151134,  0.        ,  1.        ,  0.        ],
           [ 0.90453403,  0.        ,  0.        ,  1.        ]])
    N)dtype_includedtype_excludec                0    || _         || _        || _        d S rI   )patternr  r  )rJ   r  r  r  s       rK   rL   zmake_column_selector.__init__$  s    **rM   c                 N   t          |d          st          d          |j        dd         }| j        | j        !|                    | j        | j                  }|j        }| j        '||j        	                    | j        d                   }|
                                S )zCallable for column selection to be used by a
        :class:`ColumnTransformer`.

        Parameters
        ----------
        df : dataframe of shape (n_features, n_samples)
            DataFrame to select columns from.
        ilocz=make_column_selector can only be applied to pandas dataframesNr9   )includeexcludeT)regex)r   rX   r  r  r  select_dtypesr   r  r   containsra  )rJ   dfdf_rowr   s       rK   __call__zmake_column_selector.__call__)  s     r6"" 	O   !)T-?-K))*D4F *  F ~<#))$,d)CCDD{{}}rM   rI   )r   r|  r}  r~  rL   r  rP   rM   rK   r2   r2     sP        9 9v+d$ + + + + +
    rM   r2   c                   B     e Zd ZdZdddd fd
Z fdZd Zd	 Z xZS )
r   a  A list that raises a warning whenever items are accessed.

    It is used to store the columns handled by the "remainder" entry of
    ``ColumnTransformer.transformers_``, ie ``transformers_[-1][-1]``.

    For some values of the ``ColumnTransformer`` ``transformers`` parameter,
    this list of indices will be replaced by either a list of column names or a
    boolean mask; in those cases we emit a ``FutureWarning`` the first time an
    element is accessed.

    Parameters
    ----------
    columns : list of int
        The remainder columns.

    future_dtype : {'str', 'bool'}, default=None
        The dtype that will be used by a ColumnTransformer with the same inputs
        in a future release. There is a default value because providing a
        constructor that takes a single argument is a requirement for
        subclasses of UserList, but we do not use it in practice. It would only
        be used if a user called methods that return a new list such are
        copying or concatenating `_RemainderColsList`.

    warning_was_emitted : bool, default=False
       Whether the warning for that particular list was already shown, so we
       only emit it once.

    warning_enabled : bool, default=True
        When False, the list never emits the warning nor updates
        `warning_was_emitted``. This is used to obtain a quiet copy of the list
        for use by the `ColumnTransformer` itself, so that the warning is only
        shown when a user accesses it directly.
    NFTr   warning_was_emittedwarning_enabledc                t    t                                          |           || _        || _        || _        d S rI   )rg   rL   r   r  r  )rJ   r   r   r  r  rj   s        rK   rL   z_RemainderColsList.__init__d  s;     	!!!(#6 .rM   c                 n    |                                   t                                          |          S rI   )_show_remainder_cols_warningrg   rh  )rJ   indexrj   s     rK   rh  z_RemainderColsList.__getitem__q  s-    ))+++ww""5)))rM   c                     | j         s| j        sd S d| _         dddd                    | j        | j                  }t	          j        d| dt                     d S )	NTzcolumn names (of type str)za mask array (of type bool)z:a different type depending on the ColumnTransformer inputs)r   r   NaD  
The format of the columns of the 'remainder' transformer in ColumnTransformer.transformers_ will change in version 1.7 to match the format of the other transformers.
At the moment the remainder columns are stored as indices (of type int). With the same ColumnTransformer configuration, in the future they will be stored as zp.
To use the new behavior now and suppress this warning, use ColumnTransformer(force_int_remainder_cols=False).
)category)r  r  ry   r   warningswarnFutureWarning)rJ   future_dtype_descriptions     rK   r  z/_RemainderColsList._show_remainder_cols_warningu  s    # 	4+? 	F#' /1 O$
 $
 #d!2
3
3 	! 	H
 0H H H #	
 	
 	
 	
 	
 	
rM   c                 T    |                     t          | j                             dS )zGOverride display in ipython console, otherwise the class name is shown.N)textreprdata)rJ   printerrU   s      rK   _repr_pretty_z _RemainderColsList._repr_pretty_  s"    T$)__%%%%%rM   )	r   r|  r}  r~  rL   rh  r  r  r  r  s   @rK   r   r   A  s           L !/ / / / / / /* * * * *
 
 
8& & & & & & &rM   r   c                     g }|D ]U\  }}}t          |t                    r"t          |j        |j        |j        |           }|                    |||f           V|S )Nr  )r   r   r  r   r  r   )r  r?   r   rS   rT   r   s         rK   rx   rx     s{    F , . .eWg122 	($1$+$? /	  G 	tUG,----MrM   rU  feature_namer   returnc                 0    |                     | |          S )N)rU  r  )r   )rU  r  r   s      rK   r   r     s&     )    rM   )Or~  r  collectionsr   r   	functoolsr   	itertoolsr   numbersr   r   numpyr{   scipyr	   baser   r   r   pipeliner   r   r   preprocessingr   utilsr   utils._estimator_html_reprr   utils._indexingr   r   r   utils._metadata_requestsr   utils._param_validationr   r   r   r   utils._set_outputr   r   r   utils._tagsr   utils.metadata_routingr    r!   r"   r#   r$   utils.metaestimatorsr%   utils.parallelr&   r'   utils.validationr(   r)   r*   r+   r,   r-   r.   r/   __all__r  r0   r+  rz   r  r1   r2   r   rx   r   r   rP   rM   rK   <module>r     s     ) ) ) ) ) ) ) )             " " " " " " " "           8 8 8 8 8 8 8 8 8 8 K K K K K K K K K K / / / / / /       5 5 5 5 5 5 V V V V V V V V V V . . . . . . N N N N N N N N N N N N         
 # " " " " "              4 3 3 3 3 3 . . . . . . . .	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 S
R
R  u u u u u(*: u u up'G G G  $	 	 	  "!C C C C CLV V V V V V V VrR& R& R& R& R& R& R& R&j  ),:=     rM   