code: def periodicity(freq_or_frame):
      
      if hasattr(freq_or_frame, 'rule_code'):
          rc = freq_or_frame.rule_code
          rc = rc.split('-')[0]
          factor = PER_YEAR_MAP.get(rc, None)
          if factor is not None:
              return factor / abs(freq_or_frame.n)
          else:
              raise Exception('Failed to determine periodicity. No factor mapping for %s' % freq_or_frame)
      elif isinstance(freq_or_frame, basestring):
          factor = PER_YEAR_MAP.get(freq_or_frame, None)
          if factor is not None:
              return factor
          else:
              raise Exception('Failed to determine periodicity. No factor mapping for %s' % freq_or_frame)
      elif isinstance(freq_or_frame, (pd.Series, pd.DataFrame, pd.TimeSeries)):
          freq = freq_or_frame.index.freq
          if not freq:
              freq = pd.infer_freq(freq_or_frame.index)
              if freq:
                  return periodicity(freq)
              else:
                  # Attempt to resolve it
                  import warnings
  
                  freq = guess_freq(freq_or_frame.index)
                  warnings.warn('frequency not set. guessed it to be %s' % freq)
                  return periodicity(freq)
          else:
              return periodicity(freq)
      else:
          raise ValueError("periodicity expects DataFrame, Series, or rule_code property")
docs: resolve the number of periods per year