Skip to content
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
52 changes: 25 additions & 27 deletions asv_bench/benchmarks/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,31 @@ def setup(self, dtype):


class Construction:
params = ["str", "string"]
param_names = ["dtype"]

def setup(self, dtype):
self.series_arr = tm.rands_array(nchars=10, size=10**5)
self.frame_arr = self.series_arr.reshape((50_000, 2)).copy()

# GH37371. Testing construction of string series/frames from ExtensionArrays
self.series_cat_arr = Categorical(self.series_arr)

def time_series_construction(self, dtype):
Series(self.series_arr, dtype=dtype)

def peakmem_series_construction(self, dtype):
Series(self.series_arr, dtype=dtype)

def time_frame_construction(self, dtype):
DataFrame(self.frame_arr, dtype=dtype)

def peakmem_frame_construction(self, dtype):
DataFrame(self.frame_arr, dtype=dtype)

def time_cat_series_construction(self, dtype):
Series(self.series_cat_arr, dtype=dtype)

def peakmem_cat_series_construction(self, dtype):
Series(self.series_cat_arr, dtype=dtype)
params = (
["series", "frame", "categorical_series"],
["str", "string[python]", "string[pyarrow]"],
)
param_names = ["pd_type", "dtype"]
pd_mapping = {"series": Series, "frame": DataFrame, "categorical_series": Series}
dtype_mapping = {"str": "str", "string[python]": object, "string[pyarrow]": object}

def setup(self, pd_type, dtype):
series_arr = tm.rands_array(
nchars=10, size=10**5, dtype=self.dtype_mapping[dtype]
)
if pd_type == "series":
self.arr = series_arr
elif pd_type == "frame":
self.arr = series_arr.reshape((50_000, 2)).copy()
elif pd_type == "categorical_series":
# GH37371. Testing construction of string series/frames from ExtensionArrays
self.arr = Categorical(series_arr)

def time_construction(self, pd_type, dtype):
self.pd_mapping[pd_type](self.arr, dtype=dtype)

def peakmem_construction(self, pd_type, dtype):
self.pd_mapping[pd_type](self.arr, dtype=dtype)


class Methods(Dtypes):
Expand Down