Skip to content

Commit 5821203

Browse files
committed
MAINT: Fix for future change
1 parent 001c0af commit 5821203

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/test_frame.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
)
2424

2525
import numpy as np
26+
from packaging.version import parse
2627
import pandas as pd
2728
from pandas._testing import (
2829
ensure_clean,
@@ -43,6 +44,8 @@
4344
from pandas.io.formats.style import Styler
4445
from pandas.io.parsers import TextFileReader
4546

47+
PD_LTE_15 = parse(pd.__version__) < parse("1.5.999")
48+
4649
DF = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
4750

4851

@@ -933,10 +936,16 @@ def test_types_describe() -> None:
933936
}
934937
)
935938
df.describe()
936-
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
939+
if PD_LTE_15:
940+
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
941+
df.describe(percentiles=[0.5], include="all")
942+
else:
943+
df.describe(percentiles=[0.5], include="all")
944+
if PD_LTE_15:
945+
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
946+
df.describe(exclude=[np.number])
947+
else:
937948
df.describe(percentiles=[0.5], include="all")
938-
with pytest.warns(FutureWarning, match="Treating datetime data as categorical"):
939-
df.describe(exclude=[np.number])
940949
# datetime_is_numeric param added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
941950
df.describe(datetime_is_numeric=True)
942951

0 commit comments

Comments
 (0)