Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: Override PeriodIndex.unique #23083

Merged
merged 3 commits into from Oct 11, 2018

Conversation

Projects
None yet
4 participants
@jbrockmendel
Copy link
Member

commented Oct 11, 2018

In trying to simplify the mess that is the PeriodIndex constructors, I found that PeriodIndex.unique is doing an unfortunate conversion to object-dtype. This PR avoids that and gets a nice speedup.

In [2]: pi = pd.period_range('1000Q1', periods=10000, freq='Q')
In [3]: %timeit pi.unique()
The slowest run took 6.25 times longer than the fastest. This could mean that an intermediate result is being cached.
1000 loops, best of 3: 226 µs per loop    <-- PR
10 loops, best of 3: 24.7 ms per loop     <-- master
@pep8speaks

This comment has been minimized.

Copy link

commented Oct 11, 2018

Hello @jbrockmendel! Thanks for submitting the PR.

@TomAugspurger
Copy link
Contributor

left a comment

Usually these merit a whatsnew entry.

@codecov

This comment has been minimized.

Copy link

commented Oct 11, 2018

Codecov Report

Merging #23083 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23083      +/-   ##
==========================================
+ Coverage   92.19%   92.19%   +<.01%     
==========================================
  Files         169      169              
  Lines       50911    50919       +8     
==========================================
+ Hits        46939    46947       +8     
  Misses       3972     3972
Flag Coverage Δ
#multiple 90.62% <100%> (ø) ⬆️
#single 42.3% <37.5%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/period.py 93.44% <100%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 296c251...3bd918c. Read the comment docs.

@jreback jreback added this to the 0.24.0 milestone Oct 11, 2018

@jreback jreback merged commit a86501f into pandas-dev:master Oct 11, 2018

6 checks passed

ci/circleci: py27_compat Your tests passed on CircleCI!
Details
ci/circleci: py35_ascii Your tests passed on CircleCI!
Details
ci/circleci: py36_locale Your tests passed on CircleCI!
Details
ci/circleci: py36_locale_slow Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
pandas-dev.pandas Build #20181011.10 succeeded
Details
@jreback

This comment has been minimized.

Copy link
Contributor

commented Oct 11, 2018

thanks!

@jbrockmendel jbrockmendel deleted the jbrockmendel:pi_unique branch Oct 11, 2018

brute4s99 added a commit to brute4s99/pandas that referenced this pull request Nov 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.