Skip to content

Commit 055e0ac

Browse files
committed
clarify whatsnew and parametrize tests
1 parent 1da008a commit 055e0ac

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

doc/source/whatsnew/v0.23.0.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ Conversion
375375
- Bug in :class:`TimedeltaIndex` where division by a ``Series`` would return a ``TimedeltaIndex`` instead of a ``Series`` (issue:`19042`)
376376
- Bug in :class:`Series` with ``dtype='timedelta64[ns]`` where addition or subtraction of ``TimedeltaIndex`` could return a ``Series`` with an incorrect name (issue:`19043`)
377377
- Fixed bug where comparing :class:`DatetimeIndex` failed to raise ``TypeError`` when attempting to compare timezone-aware and timezone-naive datetimelike objects (:issue:`18162`)
378-
- Bug in :class:`DatetimeIndex` where the repr was not showing the time values for the end of the day (:issue:`19030`)
378+
- Bug in :class:`DatetimeIndex` where the repr was not showing high-precision time values at the end of a day (e.g., 23:59:59.999999999) (:issue:`19030`)
379379

380380

381381
Indexing

pandas/tests/io/formats/test_format.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -883,19 +883,29 @@ def test_datetimelike_frame(self):
883883
'[10 rows x 2 columns]')
884884
assert repr(df) == expected
885885

886-
def test_datetimeindex_highprecision(self):
886+
887+
@pytest.mark.parametrize('start_date', [
888+
'2017-01-01 23:59:59.999999999',
889+
'2017-01-01 23:59:59.99999999',
890+
'2017-01-01 23:59:59.9999999',
891+
'2017-01-01 23:59:59.999999',
892+
'2017-01-01 23:59:59.99999',
893+
'2017-01-01 23:59:59.9999',
894+
])
895+
def test_datetimeindex_highprecision(self, start_date):
887896
# GH19030
888-
# Check that time values for the end of day are included in repr
889-
df = DataFrame({'A': date_range(start='2017-01-01 23:59:59.999999999',
897+
# Check that high-precision time values for the end of day are
898+
# included in repr for DatetimeIndex
899+
df = DataFrame({'A': date_range(start=start_date,
890900
freq='D', periods=5)})
891901
result = str(df)
892-
assert "23:59:59.999999999" in result
902+
assert start_date in result
893903

894-
dti = date_range(start='2017-01-01 23:59:59.999999999',
904+
dti = date_range(start=start_date,
895905
freq='D', periods=5)
896906
df = DataFrame({'A': range(5)}, index=dti)
897907
result = str(df.index)
898-
assert "23:59:59.999999999" in result
908+
assert start_date in result
899909

900910
def test_nonunicode_nonascii_alignment(self):
901911
df = DataFrame([["aa\xc3\xa4\xc3\xa4", 1], ["bbbb", 2]])
@@ -1928,19 +1938,26 @@ def test_datetimeindex(self):
19281938
result = str(s2.index)
19291939
assert 'NaT' in result
19301940

1931-
def test_datetimeindex_highprecision(self):
1941+
@pytest.mark.parametrize('start_date', [
1942+
'2017-01-01 23:59:59.999999999',
1943+
'2017-01-01 23:59:59.99999999',
1944+
'2017-01-01 23:59:59.9999999',
1945+
'2017-01-01 23:59:59.999999',
1946+
'2017-01-01 23:59:59.99999',
1947+
'2017-01-01 23:59:59.9999',
1948+
])
1949+
def test_datetimeindex_highprecision(self, start_date):
19321950
# GH19030
1933-
# Check that time values for the end of day are included in repr
1934-
s1 = Series(date_range(start='2017-01-01 23:59:59.999999999',
1935-
freq='D', periods=5))
1951+
# Check that high-precision time values for the end of day are
1952+
# included in repr for DatetimeIndex
1953+
s1 = Series(date_range(start=start_date, freq='D', periods=5))
19361954
result = str(s1)
1937-
assert "23:59:59.999999999" in result
1955+
assert start_date in result
19381956

1939-
dti = date_range(start='2017-01-01 23:59:59.999999999', freq='D',
1940-
periods=5)
1957+
dti = date_range(start=start_date, freq='D', periods=5)
19411958
s2 = Series(3, index=dti)
19421959
result = str(s2.index)
1943-
assert "23:59:59.999999999" in result
1960+
assert start_date in result
19441961

19451962
def test_timedelta64(self):
19461963

0 commit comments

Comments
 (0)