File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
import numpy as np
2
2
import pandas as pd
3
3
import pandas .util .testing as tm
4
+ import warnings
4
5
5
6
try :
6
7
from pandas .api .types import union_categoricals
@@ -122,11 +123,16 @@ def setup(self):
122
123
ncats = 100
123
124
124
125
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 ()
126
+ self .s_str_cat = pd .Series (self .s_str , dtype = "category" )
127
+ with warnings .catch_warnings (record = True ):
128
+ str_cat_type = pd .CategoricalDtype (set (self .s_str ), ordered = True )
129
+ self .s_str_cat_ordered = self .s_str .astype (str_cat_type )
130
+
127
131
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 ()
132
+ self .s_int_cat = pd .Series (self .s_int , dtype = "category" )
133
+ with warnings .catch_warnings (record = True ):
134
+ int_cat_type = pd .CategoricalDtype (set (self .s_int ), ordered = True )
135
+ self .s_int_cat_ordered = self .s_int .astype (int_cat_type )
130
136
131
137
def time_rank_string (self ):
132
138
self .s_str .rank ()
You can’t perform that action at this time.
0 commit comments