code: def validate_periods(periods):
      
      if periods is not None:
          if lib.is_float(periods):
              periods = int(periods)
          elif not lib.is_integer(periods):
              raise TypeError('periods must be a number, got {periods}'
                              .format(periods=periods))
      return periods
docs: If a `periods` argument is passed to the Datetime/Timedelta Array/Index
      constructor, cast it to an integer.
  
      Parameters
      ----------
      periods : None, float, int
  
      Returns
      -------
      periods : None or int
  
      Raises
      ------
      TypeError
          if periods is None, float, or int