Skip to content

Commit 559191b

Browse files
committed
added more testcases
1 parent cd20150 commit 559191b

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

pandas/core/series.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -5573,9 +5573,8 @@ def resample(
55735573
) -> Resampler:
55745574
if axis is not lib.no_default:
55755575
warnings.warn(
5576-
"resample axis keyword is deprecated and will be removed in a "
5577-
"future version. To group on axis=1, use obj.T.resample(...) "
5578-
"instead",
5576+
"Series resample axis keyword is deprecated and will be removed in a "
5577+
"future version.",
55795578
FutureWarning,
55805579
stacklevel=find_stack_level(),
55815580
)

pandas/tests/resample/test_resample_api.py

+30
Original file line numberDiff line numberDiff line change
@@ -977,3 +977,33 @@ def test_args_kwargs_depr(method, raises):
977977
with tm.assert_produces_warning(FutureWarning, match=warn_msg):
978978
with pytest.raises(TypeError, match=error_msg_type):
979979
func(*args, 1, 2, 3)
980+
981+
982+
def test_df_axis_param_depr():
983+
np.random.seed(1234)
984+
index = date_range(datetime(2005, 1, 1), datetime(2005, 1, 10), freq="D")
985+
index.name = "date"
986+
df = DataFrame(np.random.rand(10, 2), columns=list("AB"), index=index).T
987+
988+
# Deprication error when axis=1 is explicitly passed
989+
warning_msg = "DataFrame.resample with axis=1 is deprecated."
990+
with tm.assert_produces_warning(FutureWarning, match=warning_msg):
991+
df.resample("M", axis=1)
992+
993+
# Deprication error when axis=0 is explicitly passed
994+
df = df.T
995+
warning_msg = (
996+
"The 'axis' keyword in DataFrame.resample is deprecated and "
997+
"will be removed in a future version."
998+
)
999+
with tm.assert_produces_warning(FutureWarning, match=warning_msg):
1000+
df.resample("M", axis=0)
1001+
1002+
1003+
def test_series_axis_param_depr():
1004+
warning_msg = (
1005+
"Series resample axis keyword is deprecated and will be removed in a "
1006+
"future version."
1007+
)
1008+
with tm.assert_produces_warning(FutureWarning, match=warning_msg):
1009+
test_series.resample("H", axis=0)

0 commit comments

Comments
 (0)