Skip to content

Commit 7c50a76

Browse files
committed
add type annotation, fix namespace usage
1 parent 3247048 commit 7c50a76

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ Other
624624
- Bug in :meth:`DataFrame.sort_index` when passing ``axis="columns"`` and ``ignore_index=True`` and ``ascending=False`` not returning a :class:`RangeIndex` columns (:issue:`57293`)
625625
- Bug in :meth:`DataFrame.transform` that was returning the wrong order unless the index was monotonically increasing. (:issue:`57069`)
626626
- Bug in :meth:`DataFrame.where` where using a non-bool type array in the function would return a ``ValueError`` instead of a ``TypeError`` (:issue:`56330`)
627-
- Bug in :meth:`Index.sort_values` when passing a key function that turns values into tuples, e.g. ``key=natsort.natsort_key``, would raise ``TypeError`` (:issue:`56081`)
628627
- Bug in :meth:`Index.difference` returning too many values / incorrect values for period indexes (:issue:`58971`)
628+
- Bug in :meth:`Index.sort_values` when passing a key function that turns values into tuples, e.g. ``key=natsort.natsort_key``, would raise ``TypeError`` (:issue:`56081`)
629629
- Bug in :meth:`Series.diff` allowing non-integer values for the ``periods`` argument. (:issue:`56607`)
630630
- Bug in :meth:`Series.dt` methods in :class:`ArrowDtype` that were returning incorrect values. (:issue:`57355`)
631631
- Bug in :meth:`Series.rank` that doesn't preserve missing values for nullable integers when ``na_option='keep'``. (:issue:`56976`)

pandas/core/indexes/period.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def shift(self, periods: int = 1, freq=None) -> Self:
514514
)
515515
return self + periods
516516

517-
def _difference(self, other, sort=None):
517+
def _difference(self, other, sort=None) -> PeriodIndex:
518518
if not isinstance(other, PeriodIndex):
519519
self, other = self._maybe_downcast_for_indexing(other)
520520

pandas/tests/indexes/period/test_setops.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@ def test_difference(self, sort):
316316

317317
def test_difference_mismatched_dtypes(self, sort):
318318
# GH58971
319-
index = pd.period_range('2022-01-01', periods=5, freq='M')
320-
other = pd.Index(['2022-02', '2022-03'])
319+
index = period_range('2022-01-01', periods=5, freq='M')
320+
other = Index(['2022-02', '2022-03'])
321321

322322
idx_diff = index.difference(other, sort)
323-
expected = pd.PeriodIndex(['2022-01', '2022-04', '2022-05'], freq='M')
323+
expected = PeriodIndex(['2022-01', '2022-04', '2022-05'], freq='M')
324324
tm.assert_index_equal(idx_diff, expected)
325325

326326
idx_diff = other.difference(index, sort)
327-
expected = pd.Index([])
327+
expected = Index([])
328328
tm.assert_index_equal(idx_diff, expected)
329329

330330
def test_difference_freq(self, sort):

0 commit comments

Comments
 (0)