Skip to content

Conversation

@jbrockmendel
Copy link
Member

Avoids depending on DatetimeArray/PeriodArray methods, also avoids a couple of array allocations

In [2]: dti = pd.date_range("2016-01-01", periods=10**5, freq="S")                                                                     

In [3]: off = pd.offsets.BDay()                                                                                                        

In [4]: %timeit dti + off                                                                                                              
24.1 ms ± 202 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)  # <-- master
20.1 ms ± 664 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)  # <-- PR

@gfyoung gfyoung added Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code Datetime Datetime data dtype labels Jun 14, 2020
@jreback jreback added this to the 1.1 milestone Jun 14, 2020


cdef ndarray[int64_t] shift_bdays(const int64_t[:] i8other, int periods):
cdef:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you doc-string args

if val == NPY_NAT:
result[i] = NPY_NAT
else:
# The rest of this is effectively a copy of BusinessDay.apply
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO here to consolidate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really feasible; different types.

@jreback jreback merged commit 87d8b5e into pandas-dev:master Jun 14, 2020
@jbrockmendel jbrockmendel deleted the ref-roll branch June 14, 2020 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Datetime Datetime data dtype Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants