A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/8236 below:

CustomBusinessDay slow for increments <0 and >1 · Issue #8236 · pandas-dev/pandas · GitHub

For rolling back or for moving forward more than one step, DateOffsets create a new instance setting n accordingly. The CustomBusinessDay constructor can be very slow, however, when a large list of holidays is passed. The holidays are processed to datetime64.

As a result speed deteriorates by two magnitudes.

import pandas as pd
import datetime as dt

pd.__version__
Out[6]:
'0.14.1'
In [7]:
cbday = pd.offsets.CustomBusinessDay()
date + cbday
%timeit date + cbday
100000 loops, best of 3: 14.6 µs per loop
In [8]:
hdays = [dt.datetime(2013,1,1) for ele in range(1000)]
cbdayh = pd.offsets.CustomBusinessDay(holidays=hdays)
date + cbdayh
%timeit date + cbdayh
%timeit date + 2*cbdayh
%timeit date - 1*cbdayh
%timeit date - 10*cbday

100000 loops, best of 3: 14.6 µs per loop
100 loops, best of 3: 3.4 ms per loop
100 loops, best of 3: 6.76 ms per loop
10000 loops, best of 3: 27.8 µs per loop

I think it makes sense to have the user call to_dt64 before initializing CustomBusinessDay and to rely on the holidays to be passed in the correct format. Any other ideas how to handle this problem? Shall I create a PR for this?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4