Skip to content

Commit 10c4463

Browse files
committed
more fixups
1 parent debaee7 commit 10c4463

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

pandas/tests/indexing/test_loc.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,14 @@ def test_loc_setitem_consistency_slice_column_len(self):
632632
]
633633
df = DataFrame(values, index=mi, columns=cols)
634634

635-
msg = "will attempt to set the values inplace instead"
636-
with tm.assert_produces_warning(FutureWarning, match=msg):
635+
msg = (
636+
"will attempt to set the values inplace instead|without a format specified"
637+
)
638+
with tm.assert_produces_warning((FutureWarning, UserWarning), match=msg):
637639
df.loc[:, ("Respondent", "StartDate")] = to_datetime(
638640
df.loc[:, ("Respondent", "StartDate")]
639641
)
640-
with tm.assert_produces_warning(FutureWarning, match=msg):
642+
with tm.assert_produces_warning((FutureWarning, UserWarning), match=msg):
641643
df.loc[:, ("Respondent", "EndDate")] = to_datetime(
642644
df.loc[:, ("Respondent", "EndDate")]
643645
)

pandas/tests/resample/test_resample_api.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,19 @@ def test_selection_api_validation():
688688

689689

690690
@pytest.mark.parametrize(
691-
"col_name", ["t2", "t2x", "t2q", "T_2M", "t2p", "t2m", "t2m1", "T2M"]
691+
"col_name, warn",
692+
[
693+
("t2", None),
694+
("t2x", None),
695+
("t2q", None),
696+
("T_2M", None),
697+
("t2p", None),
698+
("t2m", UserWarning),
699+
("t2m1", UserWarning),
700+
("T2M", UserWarning),
701+
],
692702
)
693-
def test_agg_with_datetime_index_list_agg_func(col_name):
703+
def test_agg_with_datetime_index_list_agg_func(col_name, warn):
694704
# GH 22660
695705
# The parametrized column names would get converted to dates by our
696706
# date parser. Some would result in OutOfBoundsError (ValueError) while
@@ -703,7 +713,8 @@ def test_agg_with_datetime_index_list_agg_func(col_name):
703713
),
704714
columns=[col_name],
705715
)
706-
result = df.resample("1d").aggregate(["mean"])
716+
with tm.assert_produces_warning(warn, match="without a format specified"):
717+
result = df.resample("1d").aggregate(["mean"])
707718
expected = DataFrame(
708719
[47.5, 143.5, 195.5],
709720
index=date_range(start="2017-01-01", freq="D", periods=3, tz="Europe/Berlin"),

0 commit comments

Comments
 (0)