For example, in pd.date_range
, we deprecated some frequency aliases. With pandas 2.3:
>>> pd.date_range("2012-01-01", periods=3, freq='H')
FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead.
DatetimeIndex(['2012-01-01 00:00:00', '2012-01-01 01:00:00',
'2012-01-01 02:00:00'],
dtype='datetime64[ns]', freq='h')
and now with main (pandas 3.0) the deprecation is enforeced and we raise an error:
>>> pd.date_range("2012-01-01", periods=3, freq='H')
...
ValueError: Invalid frequency: H, failed to parse with error message: ValueError("Invalid frequency: H, failed to parse with error message: KeyError('H')")
However, I think that is not the best error message .. First, it's already a bit confusing that it contains the message twice. But secondly, I think it would also be nice to still keep a mapping of those aliases around, so that when parsing fails and the input is an old alias, we can provide a more informative error message (something like "invalid frequency 'H'. Did you mean 'h'?")
Comment From: Itesh90
Should I make the changes ?
Comment From: Itesh90
Made these changes in the code? you can review it.