Skip to content

fix: support Pandas 0.24 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 27, 2021
9 changes: 2 additions & 7 deletions db_dtypes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import numpy
import pandas
from pandas._libs import NaT
from pandas._typing import Scalar
import pandas.compat.numpy.function
import pandas.core.algorithms
import pandas.core.arrays
Expand Down Expand Up @@ -171,18 +170,14 @@ def all(
result = pandas.core.nanops.nanall(self._ndarray, axis=axis, skipna=skipna)
return result

def min(
self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs
) -> Scalar:
def min(self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs):
pandas.compat.numpy.function.validate_min((), kwargs)
result = pandas.core.nanops.nanmin(
values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna
)
return self._box_func(result)

def max(
self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs
) -> Scalar:
def max(self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs):
pandas.compat.numpy.function.validate_max((), kwargs)
result = pandas.core.nanops.nanmax(
values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna
Expand Down
1 change: 0 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
]

# Error if a python version is missing
nox.options.stop_on_first_error = True
nox.options.error_on_missing_interpreters = True


Expand Down
15 changes: 0 additions & 15 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,6 @@
["noxfile.py"], "google/cloud", "db_dtypes",
)


def place_before(path, text, *before_text, escape=None):
replacement = "\n".join(before_text) + "\n" + text
if escape:
for c in escape:
text = text.replace(c, "\\" + c)
s.replace([path], text, replacement)


place_before(
"noxfile.py",
"nox.options.error_on_missing_interpreters = True",
"nox.options.stop_on_first_error = True",
)

# There are no system tests for this package.
old_sessions = """
"unit",
Expand Down
12 changes: 9 additions & 3 deletions tests/unit/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
for_date_and_time = pytest.mark.parametrize("dtype", ["date", "time"])


def eq_na(a1, a2):
nna1 = pd.notna(a1)
nna2 = pd.notna(a2)
return np.array_equal(nna1, nna2) and np.array_equal(a1[nna1], a2[nna2])


@pytest.fixture(autouse=True)
def register_dtype():
import db_dtypes # noqa
Expand Down Expand Up @@ -575,8 +581,8 @@ def test_date_add():
dates = pd.Series(dates)
times = pd.Series(times)
expect = dates.astype("datetime64") + times.astype("timedelta64")[:2]
assert np.array_equal(dates + times[:2], expect, equal_nan=True)
assert np.array_equal(times[:2] + dates, expect, equal_nan=True)
assert eq_na(dates + times[:2], expect)
assert eq_na(times[:2] + dates, expect)

do = pd.Series([pd.DateOffset(days=i) for i in range(4)])
expect = dates.astype("object") + do
Expand Down Expand Up @@ -609,7 +615,7 @@ def test_date_sub():
dates = pd.Series(dates)
dates2 = pd.Series(dates2)
expect = dates.astype("datetime64") - dates2.astype("datetime64")[:2]
assert np.array_equal(dates - dates2[:2], expect, equal_nan=True)
assert eq_na(dates - dates2[:2], expect)

do = pd.Series([pd.DateOffset(days=i) for i in range(4)])
expect = dates.astype("object") - do
Expand Down