@@ -51,10 +51,10 @@ def as_pdtd(self) -> pd.Timedelta:
51
51
return pd .Timedelta (self )
52
52
53
53
@property
54
- def freq_unit (self ) -> typing .Literal ["T " , "H " , "D" ]:
54
+ def freq_unit (self ) -> typing .Literal ["min " , "h " , "D" ]:
55
55
"""Return unit of pandas frequency represented by the member.
56
56
57
- Returns either "T ", "H " or "D".
57
+ Returns either "min ", "h " or "D".
58
58
"""
59
59
return self .as_pdtd .resolution_string
60
60
@@ -64,7 +64,7 @@ def freq_value(self) -> int:
64
64
components = self .as_pdtd .components
65
65
if self .freq_unit == "D" :
66
66
return components .days
67
- elif self .freq_unit == "H " :
67
+ elif self .freq_unit == "h " :
68
68
return components .hours
69
69
else :
70
70
return components .minutes + (components .hours * 60 )
@@ -74,7 +74,7 @@ def is_intraday(self) -> bool:
74
74
"""Query if a member represents an intraday interval.
75
75
76
76
An interval is considered to be intraday if it is shorter than one
77
- day. The unit of intraday intervals will be either "T " or "H ".
77
+ day. The unit of intraday intervals will be either "min " or "h ".
78
78
"""
79
79
return self < helpers .ONE_DAY
80
80
@@ -126,7 +126,7 @@ def as_offset(
126
126
calendar
127
127
Calendar against which to evaluate custom business day for
128
128
intervals with `self.freq_unit` as "D". Not required for
129
- intervals with `self.freq_unit` as "T " or "H ".
129
+ intervals with `self.freq_unit` as "min " or "h ".
130
130
131
131
one_less
132
132
If `self.freq_unit` is "D" then:
@@ -260,7 +260,7 @@ def is_intraday(self) -> bool:
260
260
"""Query if a member represents an intraday interval.
261
261
262
262
An interval is considered to be intraday if it is shorter than one
263
- day. The unit of intraday intervals will be either "T " or "H ".
263
+ day. The unit of intraday intervals will be either "min " or "h ".
264
264
"""
265
265
return False
266
266
@@ -376,9 +376,9 @@ def create_base_intervals_enum(intervals: list[TDInterval]) -> _BaseInterval:
376
376
for intrvl in intervals :
377
377
unit , value = intrvl .freq_unit , intrvl .freq_value
378
378
td_args : tuple
379
- if unit == "T " :
379
+ if unit == "min " :
380
380
td_args = (0 , 0 , 0 , 0 , value )
381
- elif unit == "H " :
381
+ elif unit == "h " :
382
382
td_args = (0 , 0 , 0 , 0 , 0 , value )
383
383
else :
384
384
if intrvl is not TDInterval .D1 :
@@ -432,6 +432,8 @@ def to_ptinterval(interval: str | timedelta | pd.Timedelta) -> PTInterval:
432
432
f"`interval` unit must by one of { valid_units } (or lower-"
433
433
f"case) although evaluated to '{ unit } '."
434
434
)
435
+ if unit == "MIN" :
436
+ unit = "T"
435
437
436
438
else :
437
439
if interval <= timedelta (0 ):
@@ -448,7 +450,7 @@ def to_ptinterval(interval: str | timedelta | pd.Timedelta) -> PTInterval:
448
450
' example "1m" for one month.'
449
451
)
450
452
451
- valid_resolutions = ["T " , "H " , "D" ]
453
+ valid_resolutions = ["min " , "h " , "D" ]
452
454
if interval .resolution_string not in valid_resolutions :
453
455
raise ValueError (error_msg )
454
456
@@ -476,8 +478,7 @@ def raise_value_oob_error(component: str, limit: int):
476
478
}
477
479
478
480
if isinstance (interval , str ):
479
- if unit == "MIN" :
480
- unit = "T"
481
+
481
482
if value > limits [unit ]:
482
483
raise_value_oob_error (components [unit ], limits [unit ])
483
484
if unit == "T" and not value % 60 :
@@ -487,10 +488,12 @@ def raise_value_oob_error(component: str, limit: int):
487
488
488
489
else :
489
490
unit = interval .resolution_string
490
- if unit == "T" :
491
+ if unit in [ "min" , "T" ]: # "T" for compatibility pandas < 2.2
491
492
value = int (interval .total_seconds () // 60 )
492
- elif unit == "H" :
493
+ unit = "T"
494
+ elif unit in ["h" , "H" ]: # "H" for compatibility pandas < 2.2
493
495
value = int (interval .total_seconds () // 3600 )
496
+ unit = "H"
494
497
else :
495
498
value = interval .days
496
499
0 commit comments