File tree 3 files changed +11
-0
lines changed
3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Fixed regressions
20
20
- Fixed regression in :class: `RollingGroupby ` with ``sort=False `` not being respected (:issue: `36889 `)
21
21
- Fixed regression in :meth: `Series.astype ` converting ``None `` to ``"nan" `` when casting to string (:issue: `36904 `)
22
22
- Fixed regression in :class: `RollingGroupby ` causing a segmentation fault with Index of dtype object (:issue: `36727 `)
23
+ - Fixed regression in :class: `PeriodDtype ` comparing both equal and unequal to its string representation (:issue: `37265 `)
23
24
24
25
.. ---------------------------------------------------------------------------
25
26
Original file line number Diff line number Diff line change @@ -894,6 +894,9 @@ def __eq__(self, other: Any) -> bool:
894
894
895
895
return isinstance (other , PeriodDtype ) and self .freq == other .freq
896
896
897
+ def __ne__ (self , other : Any ) -> bool :
898
+ return not self .__eq__ (other )
899
+
897
900
def __setstate__ (self , state ):
898
901
# for pickle compat. __getstate__ is defined in the
899
902
# PandasExtensionDtype superclass and uses the public properties to
Original file line number Diff line number Diff line change @@ -991,3 +991,10 @@ def test_is_dtype_no_warning(check):
991
991
992
992
with tm .assert_produces_warning (None ):
993
993
check (data ["A" ])
994
+
995
+
996
+ def test_period_dtype_compare_to_string ():
997
+ # https://github.com/pandas-dev/pandas/issues/37265
998
+ dtype = PeriodDtype (freq = "M" )
999
+ assert (dtype == "period[M]" ) is True
1000
+ assert (dtype != "period[M]" ) is False
You can’t perform that action at this time.
0 commit comments