@@ -799,8 +799,8 @@ cdef class Period(object):
799
799
else :
800
800
ordinal = self .ordinal + (nanos // offset_nanos)
801
801
return Period(ordinal = ordinal, freq = self .freq)
802
- msg = ' Input cannnot be converted to Period(freq={0})'
803
- raise ValueError (msg)
802
+ msg = ' Input cannot be converted to Period(freq={0})'
803
+ raise IncompatibleFrequency (msg.format( self .freqstr) )
804
804
elif isinstance (other, offsets.DateOffset):
805
805
freqstr = frequencies.get_standard_freq(other)
806
806
base = frequencies.get_base_alias(freqstr)
@@ -849,8 +849,8 @@ cdef class Period(object):
849
849
return Period(ordinal = ordinal, freq = self .freq)
850
850
elif isinstance (other, Period):
851
851
if other.freq != self .freq:
852
- raise ValueError ( " Cannot do arithmetic with "
853
- " non-conforming periods " )
852
+ msg = _DIFFERENT_FREQ.format( self .freqstr, other.freqstr)
853
+ raise IncompatibleFrequency(msg )
854
854
if self .ordinal == tslib.iNaT or other.ordinal == tslib.iNaT:
855
855
return Period(ordinal = tslib.iNaT, freq = self .freq)
856
856
return self .ordinal - other.ordinal
@@ -865,7 +865,6 @@ cdef class Period(object):
865
865
else :
866
866
return NotImplemented
867
867
868
-
869
868
def asfreq (self , freq , how = ' E' ):
870
869
"""
871
870
Convert Period to desired frequency, either at the start or end of the
0 commit comments