BUG: Series.plot() doesn't work with CustomBusinessDay frequency · Issue #7222 · pandas-dev/pandas (original) (raw)

In IPython, trying to .plot() a Series with a CustomBusinessDay frquency produces "ValueError: Unknown freqstr: C". See below. I imagine DataFrame.plot() would have a similar issue.

import pandas as pd

from pandas.tseries.offsets import CustomBusinessDay


s = pd.Series(range(100, 121),
              index=pd.bdate_range(start='2014-05-01', end='2014-06-01',
                                   freq=CustomBusinessDay(holidays=['2014-05-26'])))

s.plot()

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-7-8a6b3fabc67e> in <module>()
      3 
      4 s = pd.Series(range(100,121), index=pd.bdate_range(start='2014-05-01', end='2014-06-01', freq=CustomBusinessDay(holidays=['2014-05-26'])))
----> 5 s.plot()

C:\Python34\lib\site-packages\pandas\tools\plotting.py in plot_series(series, label, kind, use_index, rot, xticks, yticks, xlim, ylim, ax, style, grid, legend, logx, logy, secondary_y, **kwds)
   2254                      secondary_y=secondary_y, **kwds)
   2255 
-> 2256     plot_obj.generate()
   2257     plot_obj.draw()
   2258 

C:\Python34\lib\site-packages\pandas\tools\plotting.py in generate(self)
    900         self._compute_plot_data()
    901         self._setup_subplots()
--> 902         self._make_plot()
    903         self._add_table()
    904         self._make_legend()

C:\Python34\lib\site-packages\pandas\tools\plotting.py in _make_plot(self)
   1547         self._neg_prior = np.zeros(len(self.data))
   1548 
-> 1549         if self._is_ts_plot():
   1550             data = self._maybe_convert_index(self.data)
   1551             self._make_ts_plot(data)

C:\Python34\lib\site-packages\pandas\tools\plotting.py in _is_ts_plot(self)
   1541     def _is_ts_plot(self):
   1542         # this is slightly deceptive
-> 1543         return not self.x_compat and self.use_index and self._use_dynamic_x()
   1544 
   1545     def _make_plot(self):

C:\Python34\lib\site-packages\pandas\tools\plotting.py in _use_dynamic_x(self)
   1537                 return False
   1538 
-> 1539         return (freq is not None) and self._is_dynamic_freq(freq)
   1540 
   1541     def _is_ts_plot(self):

C:\Python34\lib\site-packages\pandas\tools\plotting.py in _is_dynamic_freq(self, freq)
   1510             freq = get_base_alias(freq)
   1511         freq = get_period_alias(freq)
-> 1512         return freq is not None and self._no_base(freq)
   1513 
   1514     def _no_base(self, freq):

C:\Python34\lib\site-packages\pandas\tools\plotting.py in _no_base(self, freq)
   1518             and isinstance(self.data.index, DatetimeIndex)):
   1519             import pandas.tseries.frequencies as freqmod
-> 1520             base = freqmod.get_freq(freq)
   1521             x = self.data.index
   1522             if (base <= freqmod.FreqGroup.FR_DAY):

C:\Python34\lib\site-packages\pandas\tseries\frequencies.py in get_freq(freq)
     67 def get_freq(freq):
     68     if isinstance(freq, compat.string_types):
---> 69         base, mult = get_freq_code(freq)
     70         freq = base
     71     return freq

C:\Python34\lib\site-packages\pandas\tseries\frequencies.py in get_freq_code(freqstr)
    105 
    106     base, stride = _base_and_stride(freqstr)
--> 107     code = _period_str_to_code(base)
    108 
    109     return code, stride

C:\Python34\lib\site-packages\pandas\tseries\frequencies.py in _period_str_to_code(freqstr)
    612             alias = _period_alias_dict[freqstr]
    613         except KeyError:
--> 614             raise ValueError("Unknown freqstr: %s" % freqstr)
    615 
    616         return _period_code_map[alias]

ValueError: Unknown freqstr: C