Skip to content

Commit

Permalink
BUG: PeriodArray subtraction returning wrong results (pandas-dev#46006)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Feb 16, 2022
1 parent d633abd commit bf97db3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ I/O

Period
^^^^^^
-
- Bug in subtraction of :class:`Period` from :class:`PeriodArray` returning wrong results (:issue:`45999`)
-

Plotting
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def _sub_period(self, other):
self._check_compatible_with(other)
asi8 = self.asi8
new_data = asi8 - other.ordinal
new_data = np.array([self.freq * x for x in new_data])
new_data = np.array([self.freq.base * x for x in new_data])

if self._hasna:
new_data[self._isnan] = NaT
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/extension/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from pandas.tests.extension import base


@pytest.fixture
def dtype():
return PeriodDtype(freq="D")
@pytest.fixture(params=["D", "2D"])
def dtype(request):
return PeriodDtype(freq=request.param)


@pytest.fixture
Expand Down

0 comments on commit bf97db3

Please sign in to comment.