Skip to content

Commit 6a8390d

Browse files
author
MarcoGorelli
committed
wip
1 parent a2856e1 commit 6a8390d

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

pandas/tests/frame/methods/test_quantile.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def test_quantile_multi_empty(self, interp_method):
407407
tm.assert_frame_equal(result, expected)
408408

409409
def test_quantile_datetime(self):
410-
df = DataFrame({"a": pd.to_datetime(["2010", "2011"]), "b": [0, 5]})
410+
df = DataFrame({"a": pd.to_datetime(["2010-01-01", "2011-01-01"]), "b": [0, 5]})
411411

412412
# exclude datetime
413413
result = df.quantile(0.5, numeric_only=True)
@@ -429,7 +429,7 @@ def test_quantile_datetime(self):
429429
tm.assert_frame_equal(result, expected)
430430

431431
# axis = 1
432-
df["c"] = pd.to_datetime(["2011", "2012"])
432+
df["c"] = pd.to_datetime(["2011-01-01", "2012-01-01"])
433433
result = df[["a", "c"]].quantile(0.5, axis=1, numeric_only=False)
434434
expected = Series(
435435
[Timestamp("2010-07-02 12:00:00"), Timestamp("2011-07-02 12:00:00")],
@@ -1018,9 +1018,9 @@ def test_datelike_numeric_only(self, expected_data, expected_index, axis):
10181018
# GH 14564
10191019
df = DataFrame(
10201020
{
1021-
"a": pd.to_datetime(["2010", "2011"]),
1021+
"a": pd.to_datetime(["2010-01-01", "2011-01-01"]),
10221022
"b": [0, 5],
1023-
"c": pd.to_datetime(["2011", "2012"]),
1023+
"c": pd.to_datetime(["2011-01-01", "2012-01-01"]),
10241024
}
10251025
)
10261026
result = df[["a", "c"]].quantile(0.5, axis=axis, numeric_only=True)

pandas/tests/frame/test_reductions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def test_kurt(self):
539539
"I": [8, 9, np.nan, np.nan],
540540
"J": [1, np.nan, np.nan, np.nan],
541541
"K": Categorical(["a", np.nan, np.nan, np.nan], categories=["a"]),
542-
"L": to_datetime(["2000-1-2", "NaT", "NaT", "NaT"]),
542+
"L": to_datetime(["2000-1-2", pd.NaT, pd.NaT, pd.NaT]),
543543
"M": to_timedelta(["1 days", "nan", "nan", "nan"]),
544544
"N": [0, 1, 2, 3],
545545
},
@@ -551,8 +551,8 @@ def test_kurt(self):
551551
"I": [8, 9, np.nan, np.nan],
552552
"J": [1, np.nan, np.nan, np.nan],
553553
"K": Categorical([np.nan, "a", np.nan, np.nan], categories=["a"]),
554-
"L": to_datetime(["NaT", "2000-1-2", "NaT", "NaT"]),
555-
"M": to_timedelta(["nan", "1 days", "nan", "nan"]),
554+
"L": to_datetime([pd.NaT, "2000-1-2", pd.NaT, pd.NaT]),
555+
"M": to_timedelta([np.nan, "1 days", np.nan, np.nan]),
556556
"N": [0, 1, 2, 3],
557557
},
558558
),
@@ -567,13 +567,13 @@ def test_mode_dropna(self, dropna, expected):
567567
"C": [1, np.nan, np.nan, np.nan],
568568
"D": [np.nan, np.nan, "a", np.nan],
569569
"E": Categorical([np.nan, np.nan, "a", np.nan]),
570-
"F": to_datetime(["NaT", "2000-1-2", "NaT", "NaT"]),
570+
"F": to_datetime([pd.NaT, "2000-1-2", pd.NaT, pd.NaT]),
571571
"G": to_timedelta(["1 days", "nan", "nan", "nan"]),
572572
"H": [8, 8, 9, 9],
573573
"I": [9, 9, 8, 8],
574574
"J": [1, 1, np.nan, np.nan],
575575
"K": Categorical(["a", np.nan, "a", np.nan]),
576-
"L": to_datetime(["2000-1-2", "2000-1-2", "NaT", "NaT"]),
576+
"L": to_datetime(["2000-1-2", "2000-1-2", pd.NaT, pd.NaT]),
577577
"M": to_timedelta(["1 days", "nan", "1 days", "nan"]),
578578
"N": np.arange(4, dtype="int64"),
579579
}

pandas/tests/indexes/test_base.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -1185,10 +1185,16 @@ def test_equals_op_index_vs_mi_same_length(self):
11851185
expected = np.array([False, False, False])
11861186
tm.assert_numpy_array_equal(result, expected)
11871187

1188-
@pytest.mark.parametrize("dt_conv", [pd.to_datetime, pd.to_timedelta])
1189-
def test_dt_conversion_preserves_name(self, dt_conv):
1188+
@pytest.mark.parametrize(
1189+
"dt_conv, arg",
1190+
[
1191+
(pd.to_datetime, ["2000-01-01", "2000-01-02"]),
1192+
(pd.to_timedelta, ["01:02:03", "01:02:04"]),
1193+
],
1194+
)
1195+
def test_dt_conversion_preserves_name(self, dt_conv, arg):
11901196
# GH 10875
1191-
index = Index(["01:02:03", "01:02:04"], name="label")
1197+
index = Index(arg, name="label")
11921198
assert index.name == dt_conv(index).name
11931199

11941200
def test_cached_properties_not_settable(self):

pandas/tests/test_algos.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,8 @@ def test_value_counts_datetime_outofbounds(self):
12121212
tm.assert_series_equal(res, exp)
12131213

12141214
# GH 12424
1215-
res = to_datetime(Series(["2362-01-01", np.nan]), errors="ignore")
1215+
with tm.assert_produces_warning(UserWarning, match="Could not infer format"):
1216+
res = to_datetime(Series(["2362-01-01", np.nan]), errors="ignore")
12161217
exp = Series(["2362-01-01", np.nan], dtype=object)
12171218
tm.assert_series_equal(res, exp)
12181219

0 commit comments

Comments
 (0)