Skip to content

Commit 34a92ce

Browse files
committed
Quick fix. New M => ME broke a custom MonthEnd subclass due to freqstr
and __hash__. Unsure if I'm just using things "incorrectly"
1 parent 86ecf05 commit 34a92ce

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/_libs/tslibs/period.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -2497,7 +2497,11 @@ cdef class _Period(PeriodMixin):
24972497
>>> pd.Period('2020-01', 'D').freqstr
24982498
'D'
24992499
"""
2500-
freqstr = freq_to_period_freqstr(self.freq.n, self.freq.name)
2500+
# I have a custom MonthEnd subclass that I need to be hash compatible with MonthEnd.
2501+
name = self.freq.name
2502+
if name == 'STC-M':
2503+
name = 'ME'
2504+
freqstr = freq_to_period_freqstr(self.freq.n, name)
25012505
return freqstr
25022506

25032507
def __repr__(self) -> str:

0 commit comments

Comments
 (0)