Skip to content

Commit cc307ab

Browse files
author
MarcoGorelli
committed
🗑️ removed now outdated tests / clean inputs
1 parent 98db2b5 commit cc307ab

File tree

2 files changed

+6
-59
lines changed

2 files changed

+6
-59
lines changed

pandas/tests/indexes/datetimes/test_constructors.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -1042,27 +1042,13 @@ def test_datetimeindex_constructor_misc(self):
10421042
arr = np.array(["1/1/2005", "1/2/2005", "1/3/2005", "2005-01-04"], dtype="O")
10431043
idx4 = DatetimeIndex(arr)
10441044

1045-
# Can't be parsed consistently, need to parse each element individually
1046-
arr = [
1047-
to_datetime(date_string)
1048-
for date_string in ["1/1/2005", "1/2/2005", "1/3/2005", "2005-01-04"]
1049-
]
1050-
idx5 = DatetimeIndex(arr)
1051-
1052-
# Can't be parsed consistently, need to parse each element individually
1053-
arr = [
1054-
to_datetime(date_string)
1055-
for date_string in ["1/1/2005", "1/2/2005", "Jan 3, 2005", "2005-01-04"]
1056-
]
1057-
idx6 = DatetimeIndex(arr)
1058-
1059-
idx7 = DatetimeIndex(["12/05/2007", "25/01/2008"], dayfirst=True)
1060-
idx8 = DatetimeIndex(
1045+
idx5 = DatetimeIndex(["12/05/2007", "25/01/2008"], dayfirst=True)
1046+
idx6 = DatetimeIndex(
10611047
["2007/05/12", "2008/01/25"], dayfirst=False, yearfirst=True
10621048
)
1063-
tm.assert_index_equal(idx7, idx8)
1049+
tm.assert_index_equal(idx5, idx6)
10641050

1065-
for other in [idx2, idx3, idx4, idx5, idx6]:
1051+
for other in [idx2, idx3, idx4]:
10661052
assert (idx1.values == other.values).all()
10671053

10681054
sdate = datetime(1999, 12, 25)

pandas/tests/tools/test_to_datetime.py

+2-41
Original file line numberDiff line numberDiff line change
@@ -1225,40 +1225,6 @@ def test_iso_8601_strings_with_different_offsets_utc(self):
12251225
)
12261226
tm.assert_index_equal(result, expected)
12271227

1228-
def test_iso8601_strings_mixed_offsets_with_naive(self):
1229-
# GH 24992
1230-
# Can't parse consistently, need to parse each element in loop.
1231-
result = DatetimeIndex(
1232-
[
1233-
to_datetime(string, utc=True)
1234-
for string in [
1235-
"2018-11-28T00:00:00",
1236-
"2018-11-28T00:00:00+12:00",
1237-
"2018-11-28T00:00:00",
1238-
"2018-11-28T00:00:00+06:00",
1239-
"2018-11-28T00:00:00",
1240-
]
1241-
]
1242-
)
1243-
expected = to_datetime(
1244-
[
1245-
"2018-11-28T00:00:00",
1246-
"2018-11-27T12:00:00",
1247-
"2018-11-28T00:00:00",
1248-
"2018-11-27T18:00:00",
1249-
"2018-11-28T00:00:00",
1250-
],
1251-
utc=True,
1252-
)
1253-
tm.assert_index_equal(result, expected)
1254-
1255-
def test_iso8601_strings_mixed_offsets_with_naive_reversed(self):
1256-
items = ["2018-11-28T00:00:00+12:00", "2018-11-28T00:00:00"]
1257-
# Can't parse consistently, need to parse each element in loop.
1258-
result = [to_datetime(item, utc=True) for item in items]
1259-
expected = [to_datetime(item, utc=True) for item in list(reversed(items))][::-1]
1260-
assert result == expected
1261-
12621228
def test_mixed_offsets_with_native_datetime_raises(self):
12631229
# GH 25978
12641230

@@ -1910,9 +1876,7 @@ def test_to_datetime_overflow(self):
19101876
def test_string_na_nat_conversion(self, cache):
19111877
# GH #999, #858
19121878

1913-
strings = np.array(
1914-
["1/1/2000", "1/2/2000", np.nan, "1/4/2000, 12:34:56"], dtype=object
1915-
)
1879+
strings = np.array(["1/1/2000", "1/2/2000", np.nan, "1/4/2000"], dtype=object)
19161880

19171881
expected = np.empty(4, dtype="M8[ns]")
19181882
for i, val in enumerate(strings):
@@ -1924,10 +1888,7 @@ def test_string_na_nat_conversion(self, cache):
19241888
result = tslib.array_to_datetime(strings)[0]
19251889
tm.assert_almost_equal(result, expected)
19261890

1927-
# Can't parse in consistent format, so need to convert each individually.
1928-
result2 = DatetimeIndex(
1929-
[to_datetime(string, cache=cache) for string in strings]
1930-
)
1891+
result2 = to_datetime(strings, cache=cache)
19311892
assert isinstance(result2, DatetimeIndex)
19321893
tm.assert_numpy_array_equal(result, result2.values)
19331894

0 commit comments

Comments
 (0)