@@ -31,83 +31,62 @@ def time_maybe_convert_objects(self):
31
31
32
32
class Factorize :
33
33
34
- params = [[True , False ], ["int" , "uint" , "float" , "string" ]]
35
- param_names = ["sort" , "dtype" ]
36
-
37
- def setup (self , sort , dtype ):
38
- N = 10 ** 5
39
- data = {
40
- "int" : pd .Int64Index (np .arange (N ).repeat (5 )),
41
- "uint" : pd .UInt64Index (np .arange (N ).repeat (5 )),
42
- "float" : pd .Float64Index (np .random .randn (N ).repeat (5 )),
43
- "string" : tm .makeStringIndex (N ).repeat (5 ),
44
- }
45
- self .idx = data [dtype ]
46
-
47
- def time_factorize (self , sort , dtype ):
48
- self .idx .factorize (sort = sort )
49
-
50
-
51
- class FactorizeUnique :
52
-
53
- params = [[True , False ], ["int" , "uint" , "float" , "string" ]]
54
- param_names = ["sort" , "dtype" ]
34
+ params = [
35
+ [True , False ],
36
+ [True , False ],
37
+ ["int" , "uint" , "float" , "string" , "datetime64[ns]" , "datetime64[ns, tz]" ],
38
+ ]
39
+ param_names = ["unique" , "sort" , "dtype" ]
55
40
56
- def setup (self , sort , dtype ):
41
+ def setup (self , unique , sort , dtype ):
57
42
N = 10 ** 5
58
43
data = {
59
44
"int" : pd .Int64Index (np .arange (N )),
60
45
"uint" : pd .UInt64Index (np .arange (N )),
61
- "float" : pd .Float64Index (np .arange (N )),
46
+ "float" : pd .Float64Index (np .random . randn (N )),
62
47
"string" : tm .makeStringIndex (N ),
63
- }
64
- self .idx = data [dtype ]
65
- assert self .idx .is_unique
66
-
67
- def time_factorize (self , sort , dtype ):
48
+ "datetime64[ns]" : pd .date_range ("2011-01-01" , freq = "H" , periods = N ),
49
+ "datetime64[ns, tz]" : pd .date_range (
50
+ "2011-01-01" , freq = "H" , periods = N , tz = "Asia/Tokyo"
51
+ ),
52
+ }[dtype ]
53
+ if not unique :
54
+ data = data .repeat (5 )
55
+ self .idx = data
56
+
57
+ def time_factorize (self , unique , sort , dtype ):
68
58
self .idx .factorize (sort = sort )
69
59
70
60
71
61
class Duplicated :
72
62
73
- params = [["first" , "last" , False ], ["int" , "uint" , "float" , "string" ]]
74
- param_names = ["keep" , "dtype" ]
75
-
76
- def setup (self , keep , dtype ):
77
- N = 10 ** 5
78
- data = {
79
- "int" : pd .Int64Index (np .arange (N ).repeat (5 )),
80
- "uint" : pd .UInt64Index (np .arange (N ).repeat (5 )),
81
- "float" : pd .Float64Index (np .random .randn (N ).repeat (5 )),
82
- "string" : tm .makeStringIndex (N ).repeat (5 ),
83
- }
84
- self .idx = data [dtype ]
85
- # cache is_unique
86
- self .idx .is_unique
87
-
88
- def time_duplicated (self , keep , dtype ):
89
- self .idx .duplicated (keep = keep )
90
-
91
-
92
- class DuplicatedUniqueIndex :
93
-
94
- params = ["int" , "uint" , "float" , "string" ]
95
- param_names = ["dtype" ]
63
+ params = [
64
+ [True , False ],
65
+ ["first" , "last" , False ],
66
+ ["int" , "uint" , "float" , "string" , "datetime64[ns]" , "datetime64[ns, tz]" ],
67
+ ]
68
+ param_names = ["unique" , "keep" , "dtype" ]
96
69
97
- def setup (self , dtype ):
70
+ def setup (self , unique , keep , dtype ):
98
71
N = 10 ** 5
99
72
data = {
100
73
"int" : pd .Int64Index (np .arange (N )),
101
74
"uint" : pd .UInt64Index (np .arange (N )),
102
75
"float" : pd .Float64Index (np .random .randn (N )),
103
76
"string" : tm .makeStringIndex (N ),
104
- }
105
- self .idx = data [dtype ]
77
+ "datetime64[ns]" : pd .date_range ("2011-01-01" , freq = "H" , periods = N ),
78
+ "datetime64[ns, tz]" : pd .date_range (
79
+ "2011-01-01" , freq = "H" , periods = N , tz = "Asia/Tokyo"
80
+ ),
81
+ }[dtype ]
82
+ if not unique :
83
+ data = data .repeat (5 )
84
+ self .idx = data
106
85
# cache is_unique
107
86
self .idx .is_unique
108
87
109
- def time_duplicated_unique (self , dtype ):
110
- self .idx .duplicated ()
88
+ def time_duplicated (self , unique , keep , dtype ):
89
+ self .idx .duplicated (keep = keep )
111
90
112
91
113
92
class Hashing :
0 commit comments