Skip to content

Commit 9501758

Browse files
author
Joe Jevnik
committed
BUG: remove millisecond field that raises valueerror
1 parent 19bafbe commit 9501758

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

doc/source/whatsnew/v0.18.0.txt

+3
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,6 @@ Bug Fixes
503503
- Bug in ``.to_csv`` ignoring formatting parameters ``decimal``, ``na_rep``, ``float_format`` for float indexes (:issue:`11553`)
504504

505505
- Bug in ``DataFrame`` when masking an empty ``DataFrame`` (:issue:`11859`)
506+
507+
- Removed ``millisecond`` property of ``DatetimeIndex``. This would always raise
508+
a ``ValueError`` (:issue:`12019`).

pandas/tests/test_index.py

+6
Original file line numberDiff line numberDiff line change
@@ -4028,6 +4028,12 @@ def test_fillna_period(self):
40284028
with tm.assertRaisesRegexp(ValueError, 'Input has different freq=D from PeriodIndex\\(freq=H\\)'):
40294029
idx.fillna(pd.Period('2011-01-01', freq='D'))
40304030

4031+
def test_no_millisecond_field(self):
4032+
with self.assertRaises(AttributeError):
4033+
DatetimeIndex.millisecond
4034+
4035+
with self.assertRaises(AttributeError):
4036+
DatetimeIndex([]).millisecond
40314037

40324038
class TestTimedeltaIndex(DatetimeLike, tm.TestCase):
40334039
_holder = TimedeltaIndex

pandas/tseries/index.py

-1
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,6 @@ def _set_freq(self, value):
14691469
hour = _field_accessor('hour', 'h', "The hours of the datetime")
14701470
minute = _field_accessor('minute', 'm', "The minutes of the datetime")
14711471
second = _field_accessor('second', 's', "The seconds of the datetime")
1472-
millisecond = _field_accessor('millisecond', 'ms', "The milliseconds of the datetime")
14731472
microsecond = _field_accessor('microsecond', 'us', "The microseconds of the datetime")
14741473
nanosecond = _field_accessor('nanosecond', 'ns', "The nanoseconds of the datetime")
14751474
weekofyear = _field_accessor('weekofyear', 'woy', "The week ordinal of the year")

0 commit comments

Comments
 (0)