You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to plot the NaT (not a time) value of pandas gives an error, where plotting NaN does not.
Expected (and hereby requested) is that NaT is treated just like NaN - i.e., ignore it.
frompylabimport*importpandasaspdplot(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)
This seems related to #8914, but this example gives an error, where the example of #8914 only results in wrong axes.
This issue was posted in the matplotlib issue tracker as matplotlib/matplotlib#4000, but they believe it can only be fixed in pandas.
The text was updated successfully, but these errors were encountered:
We won't be able to handle your exact case, which is calling the matplotlib plot function. As was pointed out in their issue, there's no way for them to know about our NaT. NaT is datetime like, so float(NaT) being NaN wouldn't work.
We could handle Series.plot and DataFrame.plot, with NaTs, e.g. df.plot(x='A', y'B') where x is a Datetime column w/ some NaTs, by applying the same rules we use for missing values (NaNs).
I believe #8914 more appropriately captures that NaT should be supported in pandas plotting functions as Tom mentions we cannot do anything on the matplotlib side.
Trying to plot the NaT (not a time) value of pandas gives an error, where plotting NaN does not.
Expected (and hereby requested) is that NaT is treated just like NaN - i.e., ignore it.
Calling plot with a np.nan results in the point being silently ignored, which I believe should also happen for pd.NaT.
This seems related to #8914, but this example gives an error, where the example of #8914 only results in wrong axes.
This issue was posted in the matplotlib issue tracker as matplotlib/matplotlib#4000, but they believe it can only be fixed in pandas.
The text was updated successfully, but these errors were encountered: