Skip to content

ASV: add benchmarks for concatenating and appending of CategoricalIndex (GH38149) #39493

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 3 commits into from
Feb 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions asv_bench/benchmarks/categoricals.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,29 @@ def setup(self):
self.a = pd.Categorical(list("aabbcd") * N)
self.b = pd.Categorical(list("bbcdjk") * N)

self.idx_a = pd.CategoricalIndex(range(N), range(N))
self.idx_b = pd.CategoricalIndex(range(N + 1), range(N + 1))
self.df_a = pd.DataFrame(range(N), columns=["a"], index=self.idx_a)
self.df_b = pd.DataFrame(range(N + 1), columns=["a"], index=self.idx_b)

def time_concat(self):
pd.concat([self.s, self.s])

def time_union(self):
union_categoricals([self.a, self.b])

def time_append_overlapping_index(self):
self.idx_a.append(self.idx_a)

def time_append_non_overlapping_index(self):
self.idx_a.append(self.idx_b)

def time_concat_overlapping_index(self):
pd.concat([self.df_a, self.df_a])

def time_concat_non_overlapping_index(self):
pd.concat([self.df_a, self.df_b])


class ValueCounts:

Expand Down