File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -122,11 +122,16 @@ def setup(self):
122
122
ncats = 100
123
123
124
124
self .s_str = pd .Series (tm .makeCategoricalIndex (N , ncats )).astype (str )
125
- self .s_str_cat = self .s_str .astype ("category" )
126
- self .s_str_cat_ordered = self .s_str_cat .cat .as_ordered ()
125
+ self .s_str_cat = pd .Series (self .s_str , dtype = "category" )
126
+ with warnings .catch_warnings (record = True ):
127
+ str_cat_type = pd .CategoricalDtype (set (self .s_str ), ordered = True )
128
+ self .s_str_cat_ordered = self .s_str .astype (str_cat_type )
129
+
127
130
self .s_int = pd .Series (np .random .randint (0 , ncats , size = N ))
128
- self .s_int_cat = self .s_int .astype ("category" )
129
- self .s_int_cat_ordered = self .s_int_cat .cat .as_ordered ()
131
+ self .s_int_cat = pd .Series (self .s_int , dtype = "category" )
132
+ with warnings .catch_warnings (record = True ):
133
+ int_cat_type = pd .Categorical (set (self .s_int ), ordered = True )
134
+ self .s_int_cat_ordered = self .s_int .astype (int_cat_type )
130
135
131
136
def time_rank_string (self ):
132
137
self .s_str .rank ()
You can’t perform that action at this time.
0 commit comments