DataFrame with TimeSeries column raises TypeError in 0.17.0 when replacing ints or floats · Issue #11326 · pandas-dev/pandas (original) (raw)

>>> df = extended_df
Traceback (most recent call last):
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3066, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-14-3f216cf6821e>", line 1, in <module>
    df = extended_df
NameError: name 'extended_df' is not defined
>>> df = expanded
>>> df
Out[16]: 
                             pricing_date  exchange_id  close
pricing_date_ts                                              
1445025600      2015-10-13 20:00:00+00:00          NaN    NaN
1444939200      2015-10-13 20:00:00+00:00          NaN    NaN
1444852800      2015-10-13 20:00:00+00:00            0       NaN
1444766400      2015-10-13 20:00:00+00:00            6  0.545
1444680000      2015-10-12 20:00:00+00:00            6  0.570
1444420800      2015-10-09 20:00:00+00:00            6  0.580
1444334400      2015-10-08 20:00:00+00:00            6  0.560
1444248000      2015-10-07 20:00:00+00:00            6  0.580
1444161600      2015-10-06 20:00:00+00:00            6  0.620
1444075200      2015-10-05 20:00:00+00:00            6  0.480
1443816000      2015-10-13 20:00:00+00:00          NaN    NaN
>>> df.dtypes
Out[17]: 
pricing_date    datetime64[ns, UTC]
exchange_id                 float64
close                       float64
dtype: object
>>> df.replace(0, np.NaN)
Traceback (most recent call last):
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3066, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-18-cc26b9ec3ff7>", line 1, in <module>
    df.replace(0, np.NaN)
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/pandas/core/generic.py", line 2996, in replace
    inplace=inplace, regex=regex)
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/pandas/core/internals.py", line 2761, in replace
    return self.apply('replace', **kwargs)
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/pandas/core/internals.py", line 2710, in apply
    applied = getattr(b, f)(**kwargs)
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/pandas/core/internals.py", line 560, in replace
    mask = com.mask_missing(self.values, to_replace)
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/pandas/core/common.py", line 449, in mask_missing
    mask = arr == x
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/pandas/tseries/index.py", line 84, in wrapper
    other = _ensure_datetime64(other)
  File "/Users/josh/anaconda/envs/Openfolio/lib/python2.7/site-packages/pandas/tseries/index.py", line 111, in _ensure_datetime64
    raise TypeError('%s type object %s' % (type(other), str(other)))
TypeError: <type 'int'> type object 0