谢谢!

0 0 0

wangxishi

2020-11-05

python 根据日期条件计数

TypeError                                 Traceback (most recent call last)pandas\_libs\tslibs\offsets.pyx in pandas._libs.tslibs.offsets.BaseOffset._validate_n()TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

During handling of the above exception, another exception occurred:TypeError                                 Traceback (most recent call last)<ipython-input-100-eab4994fcd77> in <module>     22         count_businessday(start_day,end_day)     23 ---> 24 sheet['工作日'] = sheet.apply(lambda x:count_businessday(x['出院时间'],x['归档日期']),axis=1)D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, raw, result_type, args, **kwds)   7546             kwds=kwds,   7547         )-> 7548         return op.get_result()   7549    7550     def applymap(self, func) -> "DataFrame":D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\apply.py in get_result(self)    178             return self.apply_raw()    179 --> 180         return self.apply_standard()    181     182     def apply_empty_result(self):D:\ProgramData\Anaconda3\lib\site-packages\pandas\core\apply.py in apply_standard(self)    269     270     def apply_standard(self):--> 271         results, res_index = self.apply_series_generator()    272     273         # wrap resultsD:\ProgramData\Anaconda3\lib\site-packages\pandas\core\apply.py in apply_series_generator(self)    298                 for i, v in enumerate(series_gen):    299                     # ignore SettingWithCopy here in case the user mutates--> 300                     results[i] = self.f(v)    301                     if isinstance(results[i], ABCSeries):    302                         # If we have a view on v, we need to make a copy because<ipython-input-100-eab4994fcd77> in <lambda>(x)     22         count_businessday(start_day,end_day)     23 ---> 24 sheet['工作日'] = sheet.apply(lambda x:count_businessday(x['出院时间'],x['归档日期']),axis=1)<ipython-input-100-eab4994fcd77> in count_businessday(start_day, end_day)      4                                     '2020-10-05','2020-10-06','2020-10-07','2020-10-08']      5     holidays=[pd.Timestamp(i) for i in holidays]----> 6     b = CustomBusinessDay(holidays)      7     bus_day = pd.date_range(start=start_day, end=end_day, freq=b)      8     length = len(bus_day)pandas\_libs\tslibs\offsets.pyx in pandas._libs.tslibs.offsets.CustomBusinessDay.__init__()pandas\_libs\tslibs\offsets.pyx in pandas._libs.tslibs.offsets.BusinessMixin.__init__()pandas\_libs\tslibs\offsets.pyx in pandas._libs.tslibs.offsets.BaseOffset.__init__()pandas\_libs\tslibs\offsets.pyx in pandas._libs.tslibs.offsets.BaseOffset._validate_n()TypeError: `n` argument must be an integer, got <class 'list'>


0 0 0