1
1
import warnings
2
2
3
3
import numpy as np
4
- from pandas import Series
4
+ from pandas import Series , DataFrame
5
5
import pandas .util .testing as tm
6
6
7
7
@@ -12,9 +12,6 @@ class Methods(object):
12
12
def setup (self ):
13
13
self .s = Series (tm .makeStringIndex (10 ** 5 ))
14
14
15
- def time_cat (self ):
16
- self .s .str .cat (sep = ',' )
17
-
18
15
def time_center (self ):
19
16
self .s .str .center (100 )
20
17
@@ -87,6 +84,24 @@ def time_repeat(self, repeats):
87
84
self .s .str .repeat (self .repeat )
88
85
89
86
87
+ class Cat (object ):
88
+
89
+ goal_time = 0.2
90
+ params = ([None , 5 ], [None , ',' ], [None , '-' ])
91
+ param_names = ['others' , 'sep' , 'na_rep' ]
92
+
93
+ def setup (self , others , sep , na_rep ):
94
+ N = int (5e5 )
95
+ mask_gen = lambda : np .random .choice ([True , False ], N , p = [0.9 , 0.1 ])
96
+ self .s = Series (tm .makeStringIndex (N )).where (mask_gen ())
97
+ self .others = (DataFrame ({i : tm .makeStringIndex (N ).where (mask_gen ())
98
+ for i in range (others )})
99
+ if others is not None else None )
100
+
101
+ def time_cat (self , others , sep , na_rep ):
102
+ self .s .str .cat (self .others , sep = sep , na_rep = na_rep )
103
+
104
+
90
105
class Contains (object ):
91
106
92
107
goal_time = 0.2
0 commit comments