-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PERF: Performance improvement value_counts for masked arrays #48338
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
Changes from 4 commits
1de9e86
a971a04
468f238
c536467
29687c1
64ad80e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||||
import numpy as np | ||||||
|
||||||
from pandas import ( | ||||||
NA, | ||||||
Index, | ||||||
NaT, | ||||||
Series, | ||||||
|
@@ -31,6 +32,14 @@ def time_constructor_fastpath(self): | |||||
Series(self.array, index=self.idx2, name="name", fastpath=True) | ||||||
|
||||||
|
||||||
class SeriesConstructorEa: | ||||||
def setup(self): | ||||||
self.data = np.array(list(range(1_000_000))) | ||||||
|
||||||
def time_constructor(self): | ||||||
Series(data=self.data, dtype="Int64") | ||||||
|
||||||
|
||||||
class ToFrame: | ||||||
params = [["int64", "datetime64[ns]", "category", "Int64"], [None, "foo"]] | ||||||
param_names = ["dtype", "name"] | ||||||
|
@@ -166,6 +175,19 @@ def time_value_counts(self, N, dtype): | |||||
self.s.value_counts() | ||||||
|
||||||
|
||||||
class ValueCountsEa: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
? Small nitpick: not sure if we have some consistency around this, but if not, since we typically use EA as abbreviation, would keep it capitalized here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, will keep in mind for future prs |
||||||
|
||||||
params = [[10**3, 10**4, 10**5], [True, False]] | ||||||
param_names = ["N", "dropna"] | ||||||
|
||||||
def setup(self, N, dropna): | ||||||
self.s = Series(np.random.randint(0, N, size=10 * N), dtype="Int64") | ||||||
self.s.loc[1] = NA | ||||||
|
||||||
def time_value_counts(self, N, dropna): | ||||||
self.s.value_counts(dropna=dropna) | ||||||
|
||||||
|
||||||
class ValueCountsObjectDropNAFalse: | ||||||
|
||||||
params = [10**3, 10**4, 10**5] | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already have a benchmark for this in array.py (IntegerArray::time_from_integer_array), except that that one is with a tiny array and thus won't cover this aspect. But maybe add a version with a larger array in the existing benchmark? (or just make the array in that benchmark bigger)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, forgot to check for series after I found nothing for value_counts. Increased the array size for the existing benchmark. 4 values is probably a bit small to see anything with overhead from other calls that don't depend on array size