Uploaded image for project: 'Zeppelin'
  1. Zeppelin
  2. ZEPPELIN-3223

Plotting time series data raises ValueError alternate times

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.7.2, 0.7.3
    • None
    • pySpark, python-interpreter
    • None

    Description

      When a time series data of type datetime64 is plotted using matplotlib, it raises  ValueError: ordinal must be >= 1 every alternate times. 

      Here's a sample code to produce this error:

       

      import pandas as pd
      import numpy as np
      import matplotlib.pyplot as plt
      rng = pd.date_range('1/1/2000', periods=10, freq='M')
      ts = pd.Series(np.random.randn(len(rng)), index=rng)

      # Plotting the data:

      orig = plt.plot(ts)
      plt.show()

       

      Running this code for the first time results in the above mentioned ValueError, but the plot appears when the same code is run again in the same cell. But the error again returns in the third run, and thus, this error appears every alternate time. Here is the traceback:

      Traceback (most recent call last):
      File "/tmp/zeppelin_python-2526037595738258825.py", line 282, in <module>
      raise Exception(traceback.format_exc())
      Exception: Traceback (most recent call last):
      File "/tmp/zeppelin_python-2526037595738258825.py", line 275, in <module>
      exec(code, _zcUserQueryNameSpace)
      File "<stdin>", line 1, in <module>
      File "build/bdist.linux-x86_64/egg/flytxt_libs/forecasting/time_series.py", line 37, in stationarity_test
      orig = plt.plot(timeseries, color='blue', label='Original')
      File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 3318, in plot
      ret = ax.plot(*args, **kwargs)
      File "/usr/lib64/python2.7/site-packages/matplotlib/_init_.py", line 1892, in inner
      return func(ax, *args, **kwargs)
      File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_axes.py", line 1406, in plot
      for line in self._get_lines(*args, **kwargs):
      File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 407, in _grab_next_args
      for seg in self._plot_args(remaining, kwargs):
      File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 385, in _plot_args
      x, y = self._xy_from_xy(x, y)
      File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 217, in _xy_from_xy
      bx = self.axes.xaxis.update_units
      File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1424, in update_units
      self._update_axisinfo()
      File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1442, in _update_axisinfo
      self.set_major_locator(info.majloc)
      File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1543, in set_major_locator
      self.stale = True
      File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 279, in stale
      self.stale_callback(self, val)
      File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 76, in _stale_axes_callback
      self.axes.stale = val
      File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 279, in stale
      self.stale_callback(self, val)
      File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 56, in _stale_figure_callback
      self.figure.stale = val
      File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 279, in stale
      self.stale_callback(self, val)
      File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 576, in _auto_draw_if_interactive
      fig.canvas.draw_idle()
      File "/usr/local/zeppelin/interpreter/lib/python/backend_zinline.py", line 136, in draw_idle
      self.draw(*args, **kwargs)
      File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 464, in draw
      self.figure.draw(self.renderer)
      File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
      draw(artist, renderer, *args, **kwargs)
      File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1143, in draw
      renderer, self, dsu, self.suppressComposite)
      File "/usr/lib64/python2.7/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
      a.draw(renderer)
      File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
      draw(artist, renderer, *args, **kwargs)
      File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 2409, in draw
      mimage._draw_list_compositing_images(renderer, self, dsu)
      File "/usr/lib64/python2.7/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
      a.draw(renderer)
      File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
      draw(artist, renderer, *args, **kwargs)
      File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1136, in draw
      ticks_to_draw = self._update_ticks(renderer)
      File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 969, in _update_ticks
      tick_tups = [t for t in self.iter_ticks()]
      File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 912, in iter_ticks
      majorLocs = self.major.locator()
      File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 983, in _call_
      self.refresh()
      File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 1003, in refresh
      dmin, dmax = self.viewlim_to_dt()
      File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 760, in viewlim_to_dt
      return num2date(vmin, self.tz), num2date(vmax, self.tz)
      File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 401, in num2date
      return _from_ordinalf(x, tz)
      File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 254, in _from_ordinalf
      dt = datetime.datetime.fromordinal(ix).replace(tzinfo=UTC)
      ValueError: ordinal must be >= 1

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            hrishikesh91 Hrishikesh S
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: