replace traceback (original) (raw)

ValueError Traceback (most recent call last)

in ()

2 ibm = web.DataReader("IBM", "yahoo", "1993/01/01").reset_index()

3 next_date_dict = dict(zip(ibm["Date"], ibm["Date"].shift()))

----> 4 ibm_next_date = ibm["Date"].replace(next_date_dict)

5 print (ibm_next_date == ibm["Date"]).all()

/local/install/pandas_test/lib/python2.7/site-packages/pandas/core/series.pyc in replace(self, to_replace, value, method, inplace, limit)

2838

2839 if isinstance(to_replace, dict):

-> 2840 _rep_dict(result, to_replace)

2841 elif isinstance(to_replace, (list, pa.Array)):

2842

/local/install/pandas_test/lib/python2.7/site-packages/pandas/core/series.pyc in _rep_dict(rs, to_rep)

2829

2830 for d, m in masks.iteritems():

-> 2831 com._maybe_upcast_putmask(rs.values,m,d,change=change)

2832 else: # if no risk of clobbering then simple

2833 for d, sset in dd.iteritems():

/local/install/pandas_test/lib/python2.7/site-packages/pandas/core/common.pyc in _maybe_upcast_putmask(result, mask, other, dtype, change)

851 np.putmask(result, mask, other)

852 except:

--> 853 return changeit()

854

855 return result, False

/local/install/pandas_test/lib/python2.7/site-packages/pandas/core/common.pyc in changeit()

815 # we are forced to change the dtype of the result as the input isn't compatible

816 r, fill_value = _maybe_upcast(result, fill_value=other, dtype=dtype, copy=True)

--> 817 np.putmask(r, mask, other)

818

819 # we need to actually change the dtype here

ValueError: Invalid date (-1,-1,-1) when converting to NumPy datetime