3
3
4
4
import numpy as np
5
5
import pandas .util .testing as tm
6
- from pandas import DataFrame , Categorical , date_range , read_csv
6
+ from pandas import DataFrame , Categorical , date_range , read_csv , to_datetime
7
7
from pandas .io .parsers import _parser_defaults
8
8
from io import StringIO
9
9
@@ -302,7 +302,7 @@ def mem_parser_chunks(self):
302
302
303
303
class ReadCSVParseSpecialDate (StringIORewind ):
304
304
params = (['mY' , 'mdY' , 'hm' ],)
305
- params_name = ['value' ]
305
+ param_names = ['value' ]
306
306
objects = {
307
307
'mY' : '01-2019\n 10-2019\n 02/2000\n ' ,
308
308
'mdY' : '12/02/2010\n ' ,
@@ -319,4 +319,29 @@ def time_read_special_date(self, value):
319
319
names = ['Date' ], parse_dates = ['Date' ])
320
320
321
321
322
+ class ParseDateComparison (StringIORewind ):
323
+ params = ([False , True ],)
324
+ param_names = ['cache_dates' ]
325
+
326
+ def setup (self , cache_dates ):
327
+ count_elem = 10000
328
+ data = '12-02-2010\n ' * count_elem
329
+ self .StringIO_input = StringIO (data )
330
+
331
+ def time_read_csv_dayfirst (self , cache_dates ):
332
+ read_csv (self .data (self .StringIO_input ), sep = ',' , header = None ,
333
+ names = ['Date' ], parse_dates = ['Date' ], cache_dates = cache_dates ,
334
+ dayfirst = True )
335
+
336
+ def time_to_datetime_dayfirst (self , cache_dates ):
337
+ df = read_csv (self .data (self .StringIO_input ),
338
+ dtype = {'date' : str }, names = ['date' ])
339
+ to_datetime (df ['date' ], cache = cache_dates , dayfirst = True )
340
+
341
+ def time_to_datetime_format_DD_MM_YYYY (self , cache_dates ):
342
+ df = read_csv (self .data (self .StringIO_input ),
343
+ dtype = {'date' : str }, names = ['date' ])
344
+ to_datetime (df ['date' ], cache = cache_dates , format = '%d-%m-%Y' )
345
+
346
+
322
347
from ..pandas_vb_common import setup # noqa: F401
0 commit comments