Skip to content

CLN: move _na_value to DatetimeIndexOpsMixin #13997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas/tseries/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
3 changes: 0 additions & 3 deletions pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions pandas/tseries/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions pandas/tseries/tdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions pandas/tseries/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down