@@ -4673,7 +4673,9 @@ def _get_offset(name: str) -> BaseOffset:
4673
4673
offset = klass._from_name(* split[1 :])
4674
4674
except (ValueError , TypeError , KeyError ) as err:
4675
4675
# bad prefix or suffix
4676
- raise ValueError(INVALID_FREQ_ERR_MSG.format(name )) from err
4676
+ raise ValueError(INVALID_FREQ_ERR_MSG.format(
4677
+ f"{name}, failed to parse with error message: {repr(err )}")
4678
+ )
4677
4679
# cache
4678
4680
_offset_map[name] = offset
4679
4681
@@ -4757,11 +4759,17 @@ cpdef to_offset(freq, bint is_period=False):
4757
4759
)
4758
4760
name = c_OFFSET_DEPR_FREQSTR[name]
4759
4761
if is_period is True and name in c_REVERSE_OFFSET_DEPR_FREQSTR:
4760
- raise ValueError (
4761
- f" for Period, please use "
4762
- f" \' {c_REVERSE_OFFSET_DEPR_FREQSTR.get(name)}\' "
4763
- f" instead of \' {name}\' "
4764
- )
4762
+ if name.startswith(" Y" ):
4763
+ raise ValueError (
4764
+ f" for Period, please use \' Y{name[2:]}\' "
4765
+ f" instead of \' {name}\' "
4766
+ )
4767
+ else :
4768
+ raise ValueError (
4769
+ f" for Period, please use "
4770
+ f" \' {c_REVERSE_OFFSET_DEPR_FREQSTR.get(name)}\' "
4771
+ f" instead of \' {name}\' "
4772
+ )
4765
4773
elif is_period is True and name in c_OFFSET_DEPR_FREQSTR:
4766
4774
if name.startswith(" A" ):
4767
4775
warnings.warn(
@@ -4813,7 +4821,9 @@ cpdef to_offset(freq, bint is_period=False):
4813
4821
else :
4814
4822
delta = delta + offset
4815
4823
except (ValueError , TypeError ) as err:
4816
- raise ValueError (INVALID_FREQ_ERR_MSG.format(freq)) from err
4824
+ raise ValueError (INVALID_FREQ_ERR_MSG.format(
4825
+ f" {freq}, failed to parse with error message: {repr(err)}" )
4826
+ )
4817
4827
else :
4818
4828
delta = None
4819
4829
0 commit comments