Skip to content

ASV: Non-unique DataFrame index #47551

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
Jun 30, 2022
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
30 changes: 22 additions & 8 deletions asv_bench/benchmarks/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,39 @@ def time_boolean_rows_boolean(self):


class DataFrameNumericIndexing:
def setup(self):

params = [
(Int64Index, UInt64Index, Float64Index),
("unique_monotonic_inc", "nonunique_monotonic_inc"),
]
param_names = ["index_dtype", "index_structure"]

def setup(self, index, index_structure):
N = 10**5
indices = {
"unique_monotonic_inc": index(range(N)),
"nonunique_monotonic_inc": index(
list(range(55)) + [54] + list(range(55, N - 1))
),
}
self.idx_dupe = np.array(range(30)) * 99
self.df = DataFrame(np.random.randn(100000, 5))
self.df = DataFrame(np.random.randn(N, 5), index=indices[index_structure])
self.df_dup = concat([self.df, 2 * self.df, 3 * self.df])
self.bool_indexer = [True] * 50000 + [False] * 50000
self.bool_indexer = [True] * (N // 2) + [False] * (N - N // 2)

def time_iloc_dups(self):
def time_iloc_dups(self, index, index_structure):
self.df_dup.iloc[self.idx_dupe]

def time_loc_dups(self):
def time_loc_dups(self, index, index_structure):
self.df_dup.loc[self.idx_dupe]

def time_iloc(self):
def time_iloc(self, index, index_structure):
self.df.iloc[:100, 0]

def time_loc(self):
def time_loc(self, index, index_structure):
self.df.loc[:100, 0]

def time_bool_indexer(self):
def time_bool_indexer(self, index, index_structure):
self.df[self.bool_indexer]


Expand Down