class_docstr: Format a time series dataframe or list of dataframes into the a format that matches the structure learned by
      `from_pandas_dynamic`. This is done to allow for bayesian network probability fitting.
  
      Example of utilisation:
      >>> ddt = DynamicDataTransformer(p=p).fit(time_series, return_df=False)
      >>> X, Xlags = ddt.transform(time_series)
  
      >>> ddt = DynamicDataTransformer(p=p).fit(time_series, return_df=True)
      >>> df = ddt.transform(time_series)
docstr: Fits the time series. This consists memorizing:
      - Column names and column positions
      - whether a dataframe or a tuple of arrays should be returned by `transform` (details below)
  Args:
      time_series: pd.DataFrame or List of pd.DataFrame instances.
          If a list is provided each element of the list being an realisation of a time series
          (i.e. time series governed by the same processes)
          The columns of the data frame represent the variables in the model, and the *index represents
          the time index*.
          Successive events, therefore, must be indexed with one integer of difference between them too.
  
      return_df: Whether the `transform` method should return a pandas.DataFrame or a tuple with (X,Xlags)
          (Details on the documentation of the `transform` method)
  
  Returns:
      self
docstr_tok: ["Fits","the","time","series",".","This","consists","memorizing",":","-","Column","names","and","column","positions","-","whether","a","dataframe","or","a","tuple","of","arrays","should","be","returned","by","`","transform","`","(","details","below",")","Args",":","time_series",":","pd.DataFrame","or","List","of","pd.DataFrame","instances",".","If","a","list","is","provided","each","element","of","the","list","being","an","realisation","of","a","time","series","(","i.e",".","time","series","governed","by","the","same","processes",")","The","columns","of","the","data","frame","represent","the","variables","in","the","model",",","and","the","*","index","represents","the","time","index","*",".","Successive","events",",","therefore",",","must","be","indexed","with","one","integer","of","difference","between","them","too",".","return_df",":","Whether","the","`","transform","`","method","should","return","a","pandas.DataFrame","or","a","tuple","with","(","X",",","Xlags",")","(","Details","on","the","documentation","of","the","`","transform","`","method",")","Returns",":","self"]
code: def fit(
      self,
      time_series: Union[pd.DataFrame, List[pd.DataFrame]],
      return_df: bool = True,
  ) -> "DynamicDataTransformer":
      """
      Fits the time series. This consists memorizing:
          - Column names and column positions
          - whether a dataframe or a tuple of arrays should be returned by `transform` (details below)
      Args:
          time_series: pd.DataFrame or List of pd.DataFrame instances.
              If a list is provided each element of the list being an realisation of a time series
              (i.e. time series governed by the same processes)
              The columns of the data frame represent the variables in the model, and the *index represents
              the time index*.
              Successive events, therefore, must be indexed with one integer of difference between them too.
  
          return_df: Whether the `transform` method should return a pandas.DataFrame or a tuple with (X,Xlags)
              (Details on the documentation of the `transform` method)
  
      Returns:
          self
  
      """
      time_series = (
          time_series
          if isinstance(time_series, list)
          else [time_series]
      )
      self._check_input_from_pandas(time_series)
      self.columns = list(time_series[0].columns)
      self.return_df = return_df
      return self
  
file_path: causalnex/causalnex/structure/transformers.py
imports: from copy import deepcopy
  from typing import List, Tuple, Union
  import numpy
  import pandas
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.exceptions import NotFittedError
label_desc: Use image node_id 2 for calling the DynamicDataTransformer obj's underlying member method code with example usage: obj.fit(time_series, return_df) and returns: self