class_docstr: The `PatsyTransformer` offers a method to select the right columns from a dataframe as well as a DSL for
  transformations.
  
  It is inspired from R formulas. This is can be useful as a first step in the pipeline.
  
  Parameters
  ----------
  formula : str
      A patsy-compatible formula.
  return_type : Literal["matrix", "dataframe"], default="matrix"
      Either "matrix" or "dataframe", passed on to patsy.
  
  Attributes
  ----------
  design_info_ : [patsy.DesignInfo](https://patsy.readthedocs.io/en/latest/API-reference.html#patsy.DesignInfo)
      A DesignInfo object holds metadata about a design matrix.
docstr: Fits the transformer on input data `X` by constructing a design matrix given the `formula`.
  
  Parameters
  ----------
  X : array-like of shape (n_samples, n_features)
      The data to fit.
  y : array-like of shape (n_samples,), default=None
      Ignored, present for compatibility.
  
  Returns
  -------
  self : PatsyTransformer
      The fitted transformer.
code: def fit(self, X, y=None):
      """Fits the transformer on input data `X` by constructing a design matrix given the `formula`.
  
      Parameters
      ----------
      X : array-like of shape (n_samples, n_features)
          The data to fit.
      y : array-like of shape (n_samples,), default=None
          Ignored, present for compatibility.
  
      Returns
      -------
      self : PatsyTransformer
          The fitted transformer.
      """
      X_ = patsy.dmatrix(
          self.formula,
          X,
          NA_action="raise",
          return_type=self.return_type,
      )
  
      # check the number of observations hasn't changed. This ought not to
      # be necessary given NA_action='raise' above but just to be safe
      if np.asarray(X_).shape[0] != np.asarray(X).shape[0]:
          raise RuntimeError(
              "Number of observations has changed during fit. "
              "This is likely because some rows have been removed "
              "due to NA values."
          )
      self.design_info_ = X_.design_info
      return self
  
file_path: scikit-lego/sklego/preprocessing/patsytransformer.py
imports: import numpy
  from deprecated import deprecated
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 2 for calling the PatsyTransformer obj's underlying member method code with example usage: obj.fit(X, y) and returns: self