fillna with datetime and value=dictlike not working on v0.13.1 · Issue #6344 · pandas-dev/pandas (original) (raw)

df = pd.DataFrame({
              'Date':[pd.NaT, pd.Timestamp("2014-1-1")],
              'Date2':[ pd.Timestamp("2013-1-1"),pd.NaT]
              })

In [8]: df.fillna(value={'Date':df['Date2']})

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-d5273c4f5a7f> in <module>()
----> 1 df.fillna(value={'Date':df['Date2']})

/usr/lib64/python2.7/site-packages/pandas/core/generic.py in fillna(self, value, method, axis, inplace, limit, downcast)
   2172                         continue
   2173                     obj = result[k]
-> 2174                     obj.fillna(v, inplace=True)
   2175                 return result
   2176             else:

/usr/lib64/python2.7/site-packages/pandas/core/generic.py in fillna(self, value, method, axis, inplace, limit, downcast)
   2159 
   2160                 new_data = self._data.fillna(value, inplace=inplace,
-> 2161                                              downcast=downcast)
   2162 
   2163             elif isinstance(value, (dict, com.ABCSeries)):

/usr/lib64/python2.7/site-packages/pandas/core/internals.py in fillna(self, *args, **kwargs)
   2408 
   2409     def fillna(self, *args, **kwargs):
-> 2410         return self.apply('fillna', *args, **kwargs)
   2411 
   2412     def downcast(self, *args, **kwargs):

/usr/lib64/python2.7/site-packages/pandas/core/internals.py in apply(self, f, *args, **kwargs)
   2373 
   2374             else:
-> 2375                 applied = getattr(blk, f)(*args, **kwargs)
   2376 
   2377             if isinstance(applied, list):

/usr/lib64/python2.7/site-packages/pandas/core/internals.py in fillna(self, value, inplace, downcast)
   1633         values = self.values if inplace else self.values.copy()
   1634         mask = com.isnull(self.values)
-> 1635         value = self._try_fill(value)
   1636         np.putmask(values, mask, value)
   1637         return [self if inplace else

/usr/lib64/python2.7/site-packages/pandas/core/internals.py in _try_fill(self, value)
   1625     def _try_fill(self, value):
   1626         """ if we are a NaT, return the actual fill value """
-> 1627         if isinstance(value, type(tslib.NaT)) or isnull(value):
   1628             value = tslib.iNaT
   1629         return value

/usr/lib64/python2.7/site-packages/pandas/core/generic.py in __nonzero__(self)
    674         raise ValueError("The truth value of a {0} is ambiguous. "
    675                          "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
--> 676                          .format(self.__class__.__name__))
    677 
    678     __bool__ = __nonzero__

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().