title: DateTimeIndex.to_period raises a ValueError exception for many offset aliases
body: <p>I am trying to solve a very simple problem, but am running into a wall.
  I have a DateTimeIndex based on a simple dataframe like follows:</p>
  
  <pre><code>df=pd.DataFrame(
       index=pd.date_range(
          start='2017-01-01', 
          end='2017-03-04', closed=None), 
       data=np.arange(63), columns=['val']).rename_axis(index='date')
  
  In [179]: df                                                                                                                                                                                                         
  Out[179]: 
              val
  date           
  2017-01-01    0
  2017-01-02    1
  2017-01-03    2
  2017-01-04    3
  2017-01-05    4
  ...         ...
  2017-02-28   58
  2017-03-01   59
  2017-03-02   60
  2017-03-03   61
  2017-03-04   62
  
  [63 rows x 1 columns] 
  </code></pre>
  
  <p>I wish to summarize the values by periods of weekly, semi-monthly, monthly etc.
  So I tried:</p>
  
  <pre><code>In [180]: df.to_period('W').groupby('date').sum()                                                                                                                                                                    
  Out[180]: 
                         val
  date                      
  2016-12-26/2017-01-01    0
  2017-01-02/2017-01-08   28
  2017-01-09/2017-01-15   77
  2017-01-16/2017-01-22  126
  2017-01-23/2017-01-29  175
  2017-01-30/2017-02-05  224
  2017-02-06/2017-02-12  273
  2017-02-13/2017-02-19  322
  2017-02-20/2017-02-26  371
  2017-02-27/2017-03-05  357
  </code></pre>
  
  <p>That works fine for offset aliases like Y, M, D, W, T, S, L, U, N.
  But fails for SM, SMS and others listed here: <a href="https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases" rel="nofollow noreferrer">https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases</a></p>
  
  <p>It raises a ValueError exception:</p>
  
  <blockquote>
  <pre><code>In [181]: df.to_period('SMS').groupby('date').sum()               
  
  --------------------------------------------------------------------------- KeyError                                  Traceback (most recent call
  last) pandas/_libs/tslibs/frequencies.pyx in
  pandas._libs.tslibs.frequencies._period_str_to_code()
  
  KeyError: 'SMS-15'
  
  During handling of the above exception, another exception occurred:
  
  ValueError                                Traceback (most recent call
  last) &lt;ipython-input-181-6779559a0596&gt; in &lt;module&gt;
  ----&gt; 1 df.to_period('SMS').groupby('date').sum()
  
  ~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/frame.py
  in to_period(self, freq, axis, copy)    8350         axis =
  self._get_axis_number(axis)    8351         if axis == 0:
  -&gt; 8352             new_data.set_axis(1, self.index.to_period(freq=freq))    8353         elif axis == 1:   
  8354             new_data.set_axis(0,
  self.columns.to_period(freq=freq))
  
  ~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/accessor.py
  in f(self, *args, **kwargs)
       91         def _create_delegator_method(name):
       92             def f(self, *args, **kwargs):
  ---&gt; 93                 return self._delegate_method(name, *args, **kwargs)
       94 
       95             f.__name__ = name
  
  ~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/indexes/datetimelike.py
  in _delegate_method(self, name, *args, **kwargs)
      811 
      812     def _delegate_method(self, name, *args, **kwargs):
  --&gt; 813         result = operator.methodcaller(name, *args, **kwargs)(self._data)
      814         if name not in self._raw_methods:
      815             result = Index(result, name=self.name)
  
  ~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/arrays/datetimes.py
  in to_period(self, freq)    1280             freq =
  get_period_alias(freq)    1281 
  -&gt; 1282         return PeriodArray._from_datetime64(self._data, freq, tz=self.tz)    1283     1284     def to_perioddelta(self, freq):
  
  ~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/arrays/period.py
  in _from_datetime64(cls, data, freq, tz)
      273         PeriodArray[freq]
      274         """
  --&gt; 275         data, freq = dt64arr_to_periodarr(data, freq, tz)
      276         return cls(data, freq=freq)
      277 
  
  ~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/arrays/period.py
  in dt64arr_to_periodarr(data, freq, tz)
      914         data = data._values
      915 
  --&gt; 916     base, mult = libfrequencies.get_freq_code(freq)
      917     return libperiod.dt64arr_to_periodarr(data.view("i8"), base, tz), freq
      918 
  
  pandas/_libs/tslibs/frequencies.pyx in
  pandas._libs.tslibs.frequencies.get_freq_code()
  
  pandas/_libs/tslibs/frequencies.pyx in
  pandas._libs.tslibs.frequencies.get_freq_code()
  
  pandas/_libs/tslibs/frequencies.pyx in
  pandas._libs.tslibs.frequencies.get_freq_code()
  
  pandas/_libs/tslibs/frequencies.pyx in
  pandas._libs.tslibs.frequencies._period_str_to_code()
  
  ValueError: Invalid frequency: SMS-15
  
  </code></pre>
  </blockquote>
  
  <p>I am using python 3.6.5, pandas version '0.25.1'</p>