@@ -25,33 +25,31 @@ def setup(self, dtype):
25
25
26
26
27
27
class Construction :
28
- params = ["str" , "string" ]
29
- param_names = ["dtype" ]
30
-
31
- def setup (self , dtype ):
32
- self .series_arr = tm .rands_array (nchars = 10 , size = 10 ** 5 )
33
- self .frame_arr = self .series_arr .reshape ((50_000 , 2 )).copy ()
34
-
35
- # GH37371. Testing construction of string series/frames from ExtensionArrays
36
- self .series_cat_arr = Categorical (self .series_arr )
37
-
38
- def time_series_construction (self , dtype ):
39
- Series (self .series_arr , dtype = dtype )
40
-
41
- def peakmem_series_construction (self , dtype ):
42
- Series (self .series_arr , dtype = dtype )
43
-
44
- def time_frame_construction (self , dtype ):
45
- DataFrame (self .frame_arr , dtype = dtype )
46
-
47
- def peakmem_frame_construction (self , dtype ):
48
- DataFrame (self .frame_arr , dtype = dtype )
49
-
50
- def time_cat_series_construction (self , dtype ):
51
- Series (self .series_cat_arr , dtype = dtype )
52
-
53
- def peakmem_cat_series_construction (self , dtype ):
54
- Series (self .series_cat_arr , dtype = dtype )
28
+ params = (
29
+ ["series" , "frame" , "categorical_series" ],
30
+ ["str" , "string[python]" , "string[pyarrow]" ],
31
+ )
32
+ param_names = ["pd_type" , "dtype" ]
33
+ pd_mapping = {"series" : Series , "frame" : DataFrame , "categorical_series" : Series }
34
+ dtype_mapping = {"str" : "str" , "string[python]" : object , "string[pyarrow]" : object }
35
+
36
+ def setup (self , pd_type , dtype ):
37
+ series_arr = tm .rands_array (
38
+ nchars = 10 , size = 10 ** 5 , dtype = self .dtype_mapping [dtype ]
39
+ )
40
+ if pd_type == "series" :
41
+ self .arr = series_arr
42
+ elif pd_type == "frame" :
43
+ self .arr = series_arr .reshape ((50_000 , 2 )).copy ()
44
+ elif pd_type == "categorical_series" :
45
+ # GH37371. Testing construction of string series/frames from ExtensionArrays
46
+ self .arr = Categorical (series_arr )
47
+
48
+ def time_construction (self , pd_type , dtype ):
49
+ self .pd_mapping [pd_type ](self .arr , dtype = dtype )
50
+
51
+ def peakmem_construction (self , pd_type , dtype ):
52
+ self .pd_mapping [pd_type ](self .arr , dtype = dtype )
55
53
56
54
57
55
class Methods (Dtypes ):
0 commit comments