Skip to content

Commit 7beea0d

Browse files
committed
Removes references to pandas older than 1.5.0
1 parent 3e4e6f6 commit 7beea0d

File tree

4 files changed

+20
-34
lines changed

4 files changed

+20
-34
lines changed

db_dtypes/__init__.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,7 @@
4646
# nanosecond precision when boxing scalars.
4747
_NP_BOX_DTYPE = "datetime64[us]"
4848

49-
50-
# To use JSONArray and JSONDtype, you'll need Pandas 1.5.0 or later. With the removal
51-
# of Python 3.7 compatibility, the minimum Pandas version will be updated to 1.5.0.
52-
if packaging.version.Version(pandas.__version__) >= packaging.version.Version("1.5.0"):
53-
from db_dtypes.json import JSONArray, JSONArrowType, JSONDtype
54-
else:
55-
JSONArray = None
56-
JSONDtype = None
57-
49+
from db_dtypes.json import JSONArray, JSONArrowType, JSONDtype
5850

5951
@pandas.api.extensions.register_extension_dtype
6052
class TimeDtype(core.BaseDatetimeDtype):

db_dtypes/core.py

-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ def median(
186186
keepdims: bool = False,
187187
skipna: bool = True,
188188
):
189-
if not hasattr(pandas_backports, "numpy_validate_median"):
190-
raise NotImplementedError("Need pandas 1.3 or later to calculate median.")
191189

192190
pandas_backports.numpy_validate_median(
193191
(),

tests/compliance/time/test_time_compliance_1_5.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import pytest
2525

2626
# NDArrayBacked2DTests suite added in https://github.com/pandas-dev/pandas/pull/44974
27-
pytest.importorskip("pandas", minversion="1.5.0dev")
27+
pytest.importorskip("pandas")
2828

2929

3030
class Test2DCompat(base.NDArrayBacked2DTests):

tests/unit/test_dtypes.py

+18-22
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
pd = pytest.importorskip("pandas")
2121
np = pytest.importorskip("numpy")
2222

23-
pandas_release = packaging.version.parse(pd.__version__).release
24-
2523
SAMPLE_RAW_VALUES = dict(
2624
dbdate=(datetime.date(2021, 2, 2), "2021-2-3", pd.NaT),
2725
dbtime=(datetime.time(1, 2, 2), "1:2:3.5", pd.NaT),
@@ -538,39 +536,37 @@ def test_min_max_median(dtype):
538536
a = cls(data)
539537
assert a.min() == sample_values[0]
540538
assert a.max() == sample_values[-1]
541-
if pandas_release >= (1, 3):
542-
assert (
543-
a.median() == datetime.time(1, 2, 4)
544-
if dtype == "dbtime"
545-
else datetime.date(2021, 2, 3)
546-
)
539+
540+
assert (
541+
a.median() == datetime.time(1, 2, 4)
542+
if dtype == "dbtime"
543+
else datetime.date(2021, 2, 3)
544+
)
547545

548546
empty = cls([])
549547
assert empty.min() is pd.NaT
550548
assert empty.max() is pd.NaT
551-
if pandas_release >= (1, 3):
552-
assert empty.median() is pd.NaT
549+
assert empty.median() is pd.NaT
553550
empty = cls([None])
554551
assert empty.min() is pd.NaT
555552
assert empty.max() is pd.NaT
556553
assert empty.min(skipna=False) is pd.NaT
557554
assert empty.max(skipna=False) is pd.NaT
558-
if pandas_release >= (1, 3):
559-
with pytest.warns(RuntimeWarning, match="empty slice"):
560-
# It's weird that we get the warning here, and not
561-
# below. :/
562-
assert empty.median() is pd.NaT
563-
assert empty.median(skipna=False) is pd.NaT
555+
556+
with pytest.warns(RuntimeWarning, match="empty slice"):
557+
# It's weird that we get the warning here, and not
558+
# below. :/
559+
assert empty.median() is pd.NaT
560+
assert empty.median(skipna=False) is pd.NaT
564561

565562
a = _make_one(dtype)
566563
assert a.min() == sample_values[0]
567564
assert a.max() == sample_values[1]
568-
if pandas_release >= (1, 3):
569-
assert (
570-
a.median() == datetime.time(1, 2, 2, 750000)
571-
if dtype == "dbtime"
572-
else datetime.date(2021, 2, 2)
573-
)
565+
assert (
566+
a.median() == datetime.time(1, 2, 2, 750000)
567+
if dtype == "dbtime"
568+
else datetime.date(2021, 2, 2)
569+
)
574570

575571

576572
def test_date_add():

0 commit comments

Comments
 (0)