Skip to content

Commit 3fcf30f

Browse files
committed
Address comments
1 parent 50407cf commit 3fcf30f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

asv_bench/benchmarks/categoricals.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import numpy as np
22
import pandas as pd
33
import pandas.util.testing as tm
4-
from pandas.core.dtypes.concat import union_categoricals
4+
try:
5+
from pandas.api.types import union_categoricals
6+
except ImportError:
7+
try:
8+
from pandas.types.concat import union_categoricals
9+
except ImportError:
10+
pass
511

612

713
class Concat(object):
@@ -42,22 +48,22 @@ def setup(self):
4248
self.values_some_nan = list(np.tile(self.categories + [np.nan], N))
4349
self.values_all_nan = [np.nan] * len(self.values)
4450

45-
def time_constructor_regular(self):
51+
def time_regular(self):
4652
pd.Categorical(self.values, self.categories)
4753

48-
def time_constructor_fastpath(self):
54+
def time_fastpath(self):
4955
pd.Categorical(self.codes, self.cat_idx, fastpath=True)
5056

51-
def time_constructor_datetimes(self):
57+
def time_datetimes(self):
5258
pd.Categorical(self.datetimes)
5359

54-
def time_constructor_datetimes_with_nat(self):
60+
def time_datetimes_with_nat(self):
5561
pd.Categorical(self.datetimes_with_nat)
5662

57-
def time_constructor_with_nan(self):
63+
def time_with_nan(self):
5864
pd.Categorical(self.values_some_nan)
5965

60-
def time_constructor_all_nan(self):
66+
def time_all_nan(self):
6167
pd.Categorical(self.values_all_nan)
6268

6369

@@ -73,10 +79,9 @@ def setup(self, dropna):
7379
np.random.seed(2718281)
7480
arr = ['s%04d' % i for i in np.random.randint(0, n // 10, size=n)]
7581
self.ts = pd.Series(arr).astype('category')
76-
self.dropna = dropna
7782

7883
def time_value_counts(self, dropna):
79-
self.ts.value_counts(dropna=self.dropna)
84+
self.ts.value_counts(dropna=dropna)
8085

8186

8287
class Repr(object):

0 commit comments

Comments
 (0)