17
17
from pandas .util ._decorators import Appender , Substitution , cache_readonly
18
18
19
19
from pandas .core .dtypes .generic import ABCPeriod
20
+ from pandas .core .dtypes .inference import _iterable_not_string
20
21
21
22
from pandas .core .tools .datetimes import to_datetime
22
23
@@ -579,12 +580,18 @@ class BusinessHourMixin(BusinessMixin):
579
580
580
581
def __init__ (self , start = '09:00' , end = '17:00' , offset = timedelta (0 )):
581
582
# must be validated here to equality check
582
- if not isinstance (start , (tuple , list )):
583
- start = (start ,)
584
- if not isinstance (end , (tuple , list )):
585
- end = (end ,)
586
- start = tuple (map (liboffsets ._validate_business_time , start ))
587
- end = tuple (map (liboffsets ._validate_business_time , end ))
583
+ if _iterable_not_string (start ):
584
+ start = np .asarray (start )
585
+ else :
586
+ start = np .array ([start ])
587
+ if _iterable_not_string (end ):
588
+ end = np .asarray (end )
589
+ else :
590
+ end = np .array ([end ])
591
+
592
+ vliboffsets = np .vectorize (liboffsets ._validate_business_time )
593
+ start = vliboffsets (start )
594
+ end = vliboffsets (end )
588
595
589
596
# Validation of input
590
597
if len (start ) != len (end ):
@@ -594,8 +601,8 @@ def __init__(self, start='09:00', end='17:00', offset=timedelta(0)):
594
601
595
602
# sort starting and ending time by starting time
596
603
index = np .argsort (start )
597
- start = tuple (np . array ( start ) [index ])
598
- end = tuple (np . array ( end ) [index ])
604
+ start = tuple (start [index ])
605
+ end = tuple (end [index ])
599
606
600
607
total_secs = 0
601
608
for i in range (num_openings ):
0 commit comments