1
1
import numpy as np
2
- from pandas import DataFrame , Series , Index , DatetimeIndex , Timestamp
2
+ from pandas import Series , Index , DatetimeIndex , Timestamp
3
3
4
4
from .pandas_vb_common import setup # noqa
5
5
6
6
7
- class Constructors (object ):
7
+ class SeriesConstructors (object ):
8
+
9
+ goal_time = 0.2
10
+
11
+ param_names = ["data_fmt" , "with_index" ]
12
+ params = [[lambda x : x ,
13
+ list ,
14
+ lambda arr : list (arr .astype (str )),
15
+ lambda arr : dict (zip (range (len (arr )), arr )),
16
+ lambda arr : [(i , - i ) for i in arr ],
17
+ lambda arr : [[i , - i ] for i in arr ],
18
+ lambda arr : ([(i , - i ) for i in arr ][:- 1 ] + [None ]),
19
+ lambda arr : ([[i , - i ] for i in arr ][:- 1 ] + [None ])],
20
+ [False , True ]]
21
+
22
+ def setup (self , data_fmt , with_index ):
23
+ N = 10 ** 4
24
+ np .random .seed (1234 )
25
+ arr = np .random .randn (N )
26
+ self .data = data_fmt (arr )
27
+ self .index = np .arange (N ) if with_index else None
28
+
29
+ def time_series_constructor (self , data_fmt , with_index ):
30
+ Series (self .data , index = self .index )
31
+
32
+
33
+ class SeriesDtypesConstructors (object ):
8
34
9
35
goal_time = 0.2
10
36
@@ -19,12 +45,6 @@ def setup(self):
19
45
self .s = Series ([Timestamp ('20110101' ), Timestamp ('20120101' ),
20
46
Timestamp ('20130101' )] * N * 10 )
21
47
22
- def time_frame_from_ndarray (self ):
23
- DataFrame (self .arr )
24
-
25
- def time_series_from_ndarray (self ):
26
- Series (self .data , index = self .index )
27
-
28
48
def time_index_from_array_string (self ):
29
49
Index (self .arr_str )
30
50
0 commit comments