diff --git a/pandas/tseries/base.py b/pandas/tseries/base.py index d10e77d7ae45d..353823e296cf8 100644 --- a/pandas/tseries/base.py +++ b/pandas/tseries/base.py @@ -353,6 +353,9 @@ def get_duplicates(self): values = Index.get_duplicates(self) return self._simple_new(values) + _na_value = tslib.NaT + """The expected NA value to use with this index.""" + @cache_readonly def _isnan(self): """ return if each value is nan""" diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index aa50fbe316b94..01728889a8595 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -667,9 +667,6 @@ def _mpl_repr(self): # how to represent ourselves to matplotlib return tslib.ints_to_pydatetime(self.asi8, self.tz) - _na_value = tslib.NaT - """The expected NA value to use with this index.""" - @cache_readonly def _is_dates_only(self): from pandas.formats.format import _is_dates_only diff --git a/pandas/tseries/period.py b/pandas/tseries/period.py index 8126d5f1dbe87..af46162038fef 100644 --- a/pandas/tseries/period.py +++ b/pandas/tseries/period.py @@ -320,10 +320,6 @@ def _coerce_scalar_to_index(self, item): """ return PeriodIndex([item], **self._get_attributes_dict()) - @property - def _na_value(self): - return self._box_func(tslib.iNaT) - def __contains__(self, key): if isinstance(key, Period): if key.freq != self.freq: diff --git a/pandas/tseries/tdi.py b/pandas/tseries/tdi.py index 271fee6341324..a17eda3ac4288 100644 --- a/pandas/tseries/tdi.py +++ b/pandas/tseries/tdi.py @@ -282,9 +282,6 @@ def _simple_new(cls, values, name=None, freq=None, **kwargs): result._reset_identity() return result - _na_value = tslib.NaT - """The expected NA value to use with this index.""" - @property def _formatter_func(self): from pandas.formats.format import _get_format_timedelta64 diff --git a/pandas/tseries/tests/test_base.py b/pandas/tseries/tests/test_base.py index 413d0e8d90445..800f9470f9845 100644 --- a/pandas/tseries/tests/test_base.py +++ b/pandas/tseries/tests/test_base.py @@ -798,6 +798,10 @@ def test_shift(self): '2011-01-01 09:00'], name='xxx', tz=tz) tm.assert_index_equal(idx.shift(-3, freq='H'), exp) + def test_na_value(self): + self.assertIs(pd.DatetimeIndex._na_value, pd.NaT) + self.assertIs(pd.DatetimeIndex([])._na_value, pd.NaT) + class TestTimedeltaIndexOps(Ops): def setUp(self): @@ -1641,6 +1645,10 @@ def test_repeat(self): tm.assert_index_equal(res, exp) self.assertIsNone(res.freq) + def test_na_value(self): + self.assertIs(pd.TimedeltaIndex._na_value, pd.NaT) + self.assertIs(pd.TimedeltaIndex([])._na_value, pd.NaT) + class TestPeriodIndexOps(Ops): def setUp(self): @@ -2581,6 +2589,10 @@ def test_repeat(self): for res in [index.repeat(3), np.repeat(index, 3)]: tm.assert_index_equal(res, exp) + def test_na_value(self): + self.assertIs(pd.PeriodIndex._na_value, pd.NaT) + self.assertIs(pd.PeriodIndex([], freq='M')._na_value, pd.NaT) + if __name__ == '__main__': import nose