8000 Pandas NaT (not a time) not supported · Issue #4000 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Pandas NaT (not a time) not supported #4000
Closed
@jvspl

Description

@jvspl

Trying to plot the NaT (not a time) value of pandas gives an error. Feature request: treat NaT just like NaN from numpy.

from pylab import *
import pandas as pd
plot(pd.NaT,5)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-60addc339c2f> in <module>()
----> 1 plot(pd.NaT,5)

C:\Anaconda\lib\site-packages\matplotlib\pyplot.pyc in plot(*args, **kwargs)
   3091         ax.hold(hold)
   3092     try:
-> 3093         ret = ax.plot(*args, **kwargs)
   3094         draw_if_interactive()
   3095     finally:

C:\Anaconda\lib\site-packages\matplotlib\axes\_axes.pyc in plot(self, *args, **kwargs)
   1372 
   1373         for line in self._get_lines(*args, **kwargs):
-> 1374             self.add_line(line)
   1375             lines.append(line)
   1376 

C:\Anaconda\lib\site-packages\matplotlib\axes\_base.pyc in add_line(self, line)
   1484             line.set_clip_path(self.patch)
   1485 
-> 1486         self._update_line_limits(line)
   1487         if not line.get_label():
   1488             line.set_label('_line%d' % len(self.lines))

C:\Anaconda\lib\site-packages\matplotlib\axes\_base.pyc in _update_line_limits(self, line)
   1495         Figures out the data limit of the given line, updating self.dataLim.
   1496         """
-> 1497         path = line.get_path()
   1498         if path.vertices.size == 0:
   1499             return

C:\Anaconda\lib\site-packages\matplotlib\lines.pyc in get_path(self)
    863         """
    864         if self._invalidy or self._invalidx:
--> 865             self.recache()
    866         return self._path
    867 

C:\Anaconda\lib\site-packages\matplotlib\lines.pyc in recache(self, always)
    564                 x = ma.asarray(xconv, np.float_)
    565             else:
--> 566                 x = np.asarray(xconv, np.float_)
    567             x = x.ravel()
    568         else:

C:\Anaconda\lib\site-packages\numpy\core\numeric.pyc in asarray(a, dtype, order)
    460 
    461     """
--> 462     return array(a, dtype, copy=False, order=order)
    463 
    464 def asanyarray(a, dtype=None, order=None):

TypeError: float() argument must be a string or a number

Calling plot with a np.nan results in the point being silently ignored, which I believe should also happen for pd.NaT.

plot(np.nan,5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0