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 1 commit
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 @@ -299,8 +299,13 @@ class Indexing:
def setup(self):
N = 10 ** 5
self.index = pd.CategoricalIndex(range(N), range(N))
self.index_non_overlapping = pd.CategoricalIndex(range(N + 1), range(N + 1))
self.series = pd.Series(range(N), index=self.index).sort_index()
self.category = self.index[500]
self.df = pd.DataFrame(range(N), columns=["a"], index=self.index)
self.df_non_overlapping = pd.DataFrame(
range(N + 1), columns=["a"], index=self.index_non_overlapping
)

def time_get_loc(self):
self.index.get_loc(self.category)
Expand All @@ -326,6 +331,18 @@ def time_reindex_missing(self):
def time_sort_values(self):
self.index.sort_values(ascending=False)

def time_append_index(self):
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 put these with the append/concat ones instead

self.index.append(self.index)

def time_append_non_overlapping_index(self):
self.index.append(self.index_non_overlapping)

def time_concat_with_index(self):
pd.concat([self.df, self.df])

def time_concat_with_non_overlapping_index(self):
pd.concat([self.df, self.df_non_overlapping])


class SearchSorted:
def setup(self):
Expand Down