Skip to content

PERF: unstack #42704

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

Merged
merged 1 commit into from
Jul 26, 2021
Merged

PERF: unstack #42704

merged 1 commit into from
Jul 26, 2021

Conversation

jbrockmendel
Copy link
Member

from asv_bench.benchmarks.reshape import *
self = ReshapeExtensionDtype()
self.setup("Period[s]")

%timeit self.time_unstack_fast("Period[s]")
23.2 ms ± 1.15 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)   # <- master
9.37 ms ± 128 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)  # <- PR

@jreback jreback added Performance Memory or execution speed performance Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jul 25, 2021
@jreback jreback added this to the 1.4 milestone Jul 25, 2021
@@ -111,7 +111,7 @@ def setup(self, dtype):
values = np.take(list(string.ascii_letters), indices)
values = [pd.Categorical(v) for v in values.T]

self.df = DataFrame(values, index, columns)
self.df = DataFrame({i: cat for i, cat in enumerate(values)}, index, columns)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed? (only for int)? e.g. category seems to do this already

Copy link
Member Author

Choose a reason for hiding this comment

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

ATM the constructor special-cases list-of-categorical, but that behavior is deprecated. this is what we will want post-deprecation, and avoids a warning in the meantime

@jreback jreback merged commit 3da2b16 into pandas-dev:master Jul 26, 2021
@jbrockmendel jbrockmendel deleted the perf-reshape branch July 26, 2021 14:51
@jbrockmendel
Copy link
Member Author

this may have broken one of the asvs, will check

debnathshoham pushed a commit to debnathshoham/pandas that referenced this pull request Jul 27, 2021
CGe0516 pushed a commit to CGe0516/pandas that referenced this pull request Jul 29, 2021
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants