Skip to content

Commit 97c00e3

Browse files
committed
ASV: add astyping benchmark
1 parent 9f40dc7 commit 97c00e3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

asv_bench/benchmarks/categoricals.py

+18
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ def time_existing_series(self):
6767
pd.Categorical(self.series)
6868

6969

70+
class AsType:
71+
def setup(self):
72+
N = 10 ** 6
73+
74+
self.df = pd.DataFrame(
75+
np.random.default_rng()
76+
.choice(np.array(list("abcde")), 4 * N)
77+
.reshape(N, 4),
78+
columns=list("ABCD"),
79+
)
80+
81+
for col in self.df.columns:
82+
self.df[col] = self.df[col].astype("category")
83+
84+
def astype_unicode(self):
85+
[self.df[col].astype("unicode") for col in self.df.columns]
86+
87+
7088
class Concat:
7189
def setup(self):
7290
N = 10 ** 5

0 commit comments

Comments
 (0)