title: How to validate if string corresponds to a valid datetime frequency? (E.g. '1D')
body: <p>To put it short, there are several datetime functionalities in python that let you use a frequency to resample date ranges (e.g. daily, weekly, etc, used in the form of <strong><em>ts.resample('1D').apply(np.sum)</em></strong>), yet I haven't found any mechanism to validate if the string is a valid frequency.</p>
  
  <p>I looked into the documentation, where I found the <a href="https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timeseries-offset-aliases" rel="nofollow noreferrer">Offset Aliases</a>, but still no way to validate it.</p>
  
  <p>I also found a prefix_mapping with the offsets, in (pd.offsets.prefix_mapping), but I imagine to use this prefix_mapping I would have to remove the numerical values from the string (e.g. <strong>'M'</strong> instead of <strong>'3M'</strong>).</p>
  
  <p>I am also unsure if these two correspond to the same data structure.</p>
  
  <p><strong>TLDR</strong>:</p>
  
  <p>Is there any straight-forward way to validate if a string corresponds to an offset / frequency? How to ensure <em>freq</em> is valid?</p>
  
  <pre><code> freq = '2D'
   # TODO Validate freq
   pd.date_range(start='1/1/2018', end='1/09/2018', freq=freq)
  
  </code></pre>