Skip to content

Commit

Permalink
CLN: reduce overhead in setup for categoricals benchmarks in asv (pan…
Browse files Browse the repository at this point in the history
  • Loading branch information
qwhelan authored and Pingviinituutti committed Feb 28, 2019
1 parent 5ce7ba4 commit 6772d95
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions asv_bench/benchmarks/categoricals.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,19 @@ class CategoricalSlicing(object):

def setup(self, index):
N = 10**6
values = list('a' * N + 'b' * N + 'c' * N)
indices = {
'monotonic_incr': pd.Categorical(values),
'monotonic_decr': pd.Categorical(reversed(values)),
'non_monotonic': pd.Categorical(list('abc' * N))}
self.data = indices[index]
categories = ['a', 'b', 'c']
values = [0] * N + [1] * N + [2] * N
if index == 'monotonic_incr':
self.data = pd.Categorical.from_codes(values,
categories=categories)
elif index == 'monotonic_decr':
self.data = pd.Categorical.from_codes(list(reversed(values)),
categories=categories)
elif index == 'non_monotonic':
self.data = pd.Categorical.from_codes([0, 1, 2] * N,
categories=categories)
else:
raise ValueError('Invalid index param: {}'.format(index))

self.scalar = 10000
self.list = list(range(10000))
Expand Down

0 comments on commit 6772d95

Please sign in to comment.