diff --git a/doc/source/whatsnew/v0.18.0.txt b/doc/source/whatsnew/v0.18.0.txt index 9ebed15c05246..19181fa86f7ef 100644 --- a/doc/source/whatsnew/v0.18.0.txt +++ b/doc/source/whatsnew/v0.18.0.txt @@ -503,3 +503,6 @@ Bug Fixes - Bug in ``.to_csv`` ignoring formatting parameters ``decimal``, ``na_rep``, ``float_format`` for float indexes (:issue:`11553`) - Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`) + +- Removed ``millisecond`` property of ``DatetimeIndex``. This would always raise + a ``ValueError`` (:issue:`12019`). diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py index a240b8c1c1e78..28db57a351ab7 100644 --- a/pandas/tests/test_index.py +++ b/pandas/tests/test_index.py @@ -4028,6 +4028,12 @@ def test_fillna_period(self): with tm.assertRaisesRegexp(ValueError, 'Input has different freq=D from PeriodIndex\\(freq=H\\)'): idx.fillna(pd.Period('2011-01-01', freq='D')) + def test_no_millisecond_field(self): + with self.assertRaises(AttributeError): + DatetimeIndex.millisecond + + with self.assertRaises(AttributeError): + DatetimeIndex([]).millisecond class TestTimedeltaIndex(DatetimeLike, tm.TestCase): _holder = TimedeltaIndex diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index 3e1ba006df5b7..166fcf759c7e1 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -1469,7 +1469,6 @@ def _set_freq(self, value): hour = _field_accessor('hour', 'h', "The hours of the datetime") minute = _field_accessor('minute', 'm', "The minutes of the datetime") second = _field_accessor('second', 's', "The seconds of the datetime") - millisecond = _field_accessor('millisecond', 'ms', "The milliseconds of the datetime") microsecond = _field_accessor('microsecond', 'us', "The microseconds of the datetime") nanosecond = _field_accessor('nanosecond', 'ns', "The nanoseconds of the datetime") weekofyear = _field_accessor('weekofyear', 'woy', "The week ordinal of the year")