code: def _apply_gap_for_expanding_primitives(
      x: Union[Series, pd.Index],
      gap: Union[int, str],
  ) -> Optional[Series]:
      if not isinstance(gap, int):
          raise TypeError(
              "String offsets are not supported for the gap parameter in Expanding primitives",
          )
      if isinstance(x, pd.Index):
          return x.to_series().shift(gap)
      return x.shift(gap)
  
file_path: featuretools/featuretools/primitives/standard/transform/time_series/utils.py
imports: from typing import Callable, Optional, Union
  import numpy
  import pandas
  from pandas import Series
  from pandas.core.window.rolling import Rolling
  from pandas.tseries.frequencies import to_offset
label_desc: Use image node_id 7 for calling a global function with example usage: _apply_gap_for_expanding_primitives(x, gap) and returns: x, x