@@ -167,10 +167,9 @@ def test_parse_cols_int(self):
167
167
168
168
dfref = self .get_csv_refdf ('test1' )
169
169
dfref = dfref .reindex (columns = ['A' , 'B' , 'C' ])
170
- df1 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True ,
171
- parse_cols = 3 )
170
+ df1 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_cols = 3 )
172
171
df2 = self .get_exceldf ('test1' , 'Sheet2' , skiprows = [1 ], index_col = 0 ,
173
- parse_dates = True , parse_cols = 3 )
172
+ parse_cols = 3 )
174
173
# TODO add index to xls file)
175
174
tm .assert_frame_equal (df1 , dfref , check_names = False )
176
175
tm .assert_frame_equal (df2 , dfref , check_names = False )
@@ -179,10 +178,9 @@ def test_parse_cols_list(self):
179
178
180
179
dfref = self .get_csv_refdf ('test1' )
181
180
dfref = dfref .reindex (columns = ['B' , 'C' ])
182
- df1 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True ,
181
+ df1 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 ,
183
182
parse_cols = [0 , 2 , 3 ])
184
183
df2 = self .get_exceldf ('test1' , 'Sheet2' , skiprows = [1 ], index_col = 0 ,
185
- parse_dates = True ,
186
184
parse_cols = [0 , 2 , 3 ])
187
185
# TODO add index to xls file)
188
186
tm .assert_frame_equal (df1 , dfref , check_names = False )
@@ -193,28 +191,28 @@ def test_parse_cols_str(self):
193
191
dfref = self .get_csv_refdf ('test1' )
194
192
195
193
df1 = dfref .reindex (columns = ['A' , 'B' , 'C' ])
196
- df2 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True ,
194
+ df2 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 ,
197
195
parse_cols = 'A:D' )
198
196
df3 = self .get_exceldf ('test1' , 'Sheet2' , skiprows = [1 ], index_col = 0 ,
199
- parse_dates = True , parse_cols = 'A:D' )
197
+ parse_cols = 'A:D' )
200
198
# TODO add index to xls, read xls ignores index name ?
201
199
tm .assert_frame_equal (df2 , df1 , check_names = False )
202
200
tm .assert_frame_equal (df3 , df1 , check_names = False )
203
201
204
202
df1 = dfref .reindex (columns = ['B' , 'C' ])
205
- df2 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True ,
203
+ df2 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 ,
206
204
parse_cols = 'A,C,D' )
207
205
df3 = self .get_exceldf ('test1' , 'Sheet2' , skiprows = [1 ], index_col = 0 ,
208
- parse_dates = True , parse_cols = 'A,C,D' )
206
+ parse_cols = 'A,C,D' )
209
207
# TODO add index to xls file
210
208
tm .assert_frame_equal (df2 , df1 , check_names = False )
211
209
tm .assert_frame_equal (df3 , df1 , check_names = False )
212
210
213
211
df1 = dfref .reindex (columns = ['B' , 'C' ])
214
- df2 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True ,
212
+ df2 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 ,
215
213
parse_cols = 'A,C:D' )
216
214
df3 = self .get_exceldf ('test1' , 'Sheet2' , skiprows = [1 ], index_col = 0 ,
217
- parse_dates = True , parse_cols = 'A,C:D' )
215
+ parse_cols = 'A,C:D' )
218
216
tm .assert_frame_equal (df2 , df1 , check_names = False )
219
217
tm .assert_frame_equal (df3 , df1 , check_names = False )
220
218
@@ -251,23 +249,23 @@ def test_excel_table_sheet_by_index(self):
251
249
excel = self .get_excelfile ('test1' )
252
250
dfref = self .get_csv_refdf ('test1' )
253
251
254
- df1 = read_excel (excel , 0 , index_col = 0 , parse_dates = True )
255
- df2 = read_excel (excel , 1 , skiprows = [1 ], index_col = 0 , parse_dates = True )
252
+ df1 = read_excel (excel , 0 , index_col = 0 )
253
+ df2 = read_excel (excel , 1 , skiprows = [1 ], index_col = 0 )
256
254
tm .assert_frame_equal (df1 , dfref , check_names = False )
257
255
tm .assert_frame_equal (df2 , dfref , check_names = False )
258
256
259
- df1 = excel .parse (0 , index_col = 0 , parse_dates = True )
260
- df2 = excel .parse (1 , skiprows = [1 ], index_col = 0 , parse_dates = True )
257
+ df1 = excel .parse (0 , index_col = 0 )
258
+ df2 = excel .parse (1 , skiprows = [1 ], index_col = 0 )
261
259
tm .assert_frame_equal (df1 , dfref , check_names = False )
262
260
tm .assert_frame_equal (df2 , dfref , check_names = False )
263
261
264
- df3 = read_excel (excel , 0 , index_col = 0 , parse_dates = True , skipfooter = 1 )
265
- df4 = read_excel (excel , 0 , index_col = 0 , parse_dates = True , skip_footer = 1 )
262
+ df3 = read_excel (excel , 0 , index_col = 0 , skipfooter = 1 )
263
+ df4 = read_excel (excel , 0 , index_col = 0 , skip_footer = 1 )
266
264
tm .assert_frame_equal (df3 , df1 .ix [:- 1 ])
267
265
tm .assert_frame_equal (df3 , df4 )
268
266
269
- df3 = excel .parse (0 , index_col = 0 , parse_dates = True , skipfooter = 1 )
270
- df4 = excel .parse (0 , index_col = 0 , parse_dates = True , skip_footer = 1 )
267
+ df3 = excel .parse (0 , index_col = 0 , skipfooter = 1 )
268
+ df4 = excel .parse (0 , index_col = 0 , skip_footer = 1 )
271
269
tm .assert_frame_equal (df3 , df1 .ix [:- 1 ])
272
270
tm .assert_frame_equal (df3 , df4 )
273
271
@@ -279,16 +277,15 @@ def test_excel_table(self):
279
277
280
278
dfref = self .get_csv_refdf ('test1' )
281
279
282
- df1 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True )
283
- df2 = self .get_exceldf ('test1' , 'Sheet2' , skiprows = [1 ], index_col = 0 ,
284
- parse_dates = True )
280
+ df1 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 )
281
+ df2 = self .get_exceldf ('test1' , 'Sheet2' , skiprows = [1 ], index_col = 0 )
285
282
# TODO add index to file
286
283
tm .assert_frame_equal (df1 , dfref , check_names = False )
287
284
tm .assert_frame_equal (df2 , dfref , check_names = False )
288
285
289
- df3 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True ,
286
+ df3 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 ,
290
287
skipfooter = 1 )
291
- df4 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 , parse_dates = True ,
288
+ df4 = self .get_exceldf ('test1' , 'Sheet1' , index_col = 0 ,
292
289
skip_footer = 1 )
293
290
tm .assert_frame_equal (df3 , df1 .ix [:- 1 ])
294
291
tm .assert_frame_equal (df3 , df4 )
@@ -389,7 +386,7 @@ def test_reading_all_sheets_with_blank(self):
389
386
basename = 'blank_with_header'
390
387
dfs = self .get_exceldf (basename , sheetname = None )
391
388
expected_keys = ['Sheet1' , 'Sheet2' , 'Sheet3' ]
392
- tm .assert_contains_all (expected_keys , dfs .keys ())
389
+ tm .assert_contains_all (expected_keys , dfs .keys ())
393
390
394
391
# GH6403
395
392
def test_read_excel_blank (self ):
@@ -411,14 +408,14 @@ class XlrdTests(ReadingTestsBase):
411
408
def test_excel_read_buffer (self ):
412
409
413
410
pth = os .path .join (self .dirpath , 'test1' + self .ext )
414
- expected = read_excel (pth , 'Sheet1' , index_col = 0 , parse_dates = True )
411
+ expected = read_excel (pth , 'Sheet1' , index_col = 0 )
415
412
with open (pth , 'rb' ) as f :
416
- actual = read_excel (f , 'Sheet1' , index_col = 0 , parse_dates = True )
413
+ actual = read_excel (f , 'Sheet1' , index_col = 0 )
417
414
tm .assert_frame_equal (expected , actual )
418
415
419
416
with open (pth , 'rb' ) as f :
420
417
xls = ExcelFile (f )
421
- actual = read_excel (xls , 'Sheet1' , index_col = 0 , parse_dates = True )
418
+ actual = read_excel (xls , 'Sheet1' , index_col = 0 )
422
419
tm .assert_frame_equal (expected , actual )
423
420
424
421
def test_read_xlrd_Book (self ):
@@ -680,7 +677,7 @@ def test_excel_oldindex_format(self):
680
677
tm .assert_frame_equal (actual , expected , check_names = False )
681
678
682
679
def test_read_excel_bool_header_arg (self ):
683
- #GH 6114
680
+ # GH 6114
684
681
for arg in [True , False ]:
685
682
with tm .assertRaises (TypeError ):
686
683
pd .read_excel (os .path .join (self .dirpath , 'test1' + self .ext ),
@@ -692,6 +689,19 @@ def test_read_excel_chunksize(self):
692
689
pd .read_excel (os .path .join (self .dirpath , 'test1' + self .ext ),
693
690
chunksize = 100 )
694
691
692
+ def test_read_excel_parse_dates (self ):
693
+ # GH 11544
694
+ with tm .assertRaises (NotImplementedError ):
695
+ pd .read_excel (os .path .join (self .dirpath , 'test1' + self .ext ),
696
+ parse_dates = True )
697
+
698
+ def test_read_excel_date_parser (self ):
699
+ # GH 11544
700
+ with tm .assertRaises (NotImplementedError ):
701
+ dateparse = lambda x : pd .datetime .strptime (x , '%Y-%m-%d %H:%M:%S' )
702
+ pd .read_excel (os .path .join (self .dirpath , 'test1' + self .ext ),
703
+ date_parser = dateparse )
704
+
695
705
def test_read_excel_skiprows_list (self ):
696
706
#GH 4903
697
707
actual = pd .read_excel (os .path .join (self .dirpath , 'testskiprows' + self .ext ),
@@ -1093,7 +1103,7 @@ def test_to_excel_periodindex(self):
1093
1103
xp .to_excel (path , 'sht1' )
1094
1104
1095
1105
reader = ExcelFile (path )
1096
- rs = read_excel (reader , 'sht1' , index_col = 0 , parse_dates = True )
1106
+ rs = read_excel (reader , 'sht1' , index_col = 0 )
1097
1107
tm .assert_frame_equal (xp , rs .to_period ('M' ))
1098
1108
1099
1109
def test_to_excel_multiindex (self ):
0 commit comments