File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -5275,6 +5275,16 @@ def _get_offset(name: str) -> BaseOffset:
52755275
52765276 return _offset_map[name]
52775277
5278+ deprecated_to_valid_alias = {
5279+ " H" : " h" ,
5280+ " BH" : " bh" ,
5281+ " CBH" : " cbh" ,
5282+ " T" : " min" ,
5283+ " S" : " s" ,
5284+ " L" : " ms" ,
5285+ " U" : " us" ,
5286+ " N" : " ns" ,
5287+ }
52785288
52795289cpdef to_offset(freq , bint is_period = False ):
52805290 """
@@ -5389,6 +5399,8 @@ cpdef to_offset(freq, bint is_period=False):
53895399 # If n==0, then stride_sign is already incorporated
53905400 # into the offset
53915401 offset *= stride_sign
5402+ elif name in deprecated_to_valid_alias:
5403+ raise ValueError (f" Did you mean '{deprecated_to_valid_alias[name]}'" )
53925404 else :
53935405 stride = int (stride)
53945406 offset = _get_offset(name)
Original file line number Diff line number Diff line change @@ -1156,6 +1156,9 @@ def test_offset_multiplication(
11561156
11571157 tm .assert_series_equal (resultarray , expectedarray )
11581158
1159+ def test_offset_deprecated_error ():
1160+ with pytest .raises (match = r"Did you mean 'h'?" ):
1161+ date_range ("2012-01-01" , periods = 3 , freq = 'H' )
11591162
11601163def test_dateoffset_operations_on_dataframes (performance_warning ):
11611164 # GH 47953
You can’t perform that action at this time.
0 commit comments