20
20
TextParser , TextFileReader )
21
21
from pandas .io .excel import ExcelFile , ExcelWriter , read_excel
22
22
from pandas .util .testing import (assert_almost_equal ,
23
- assert_series_equal ,
23
+ assert_series_equal ,
24
24
network ,
25
25
ensure_clean )
26
26
import pandas .util .testing as tm
34
34
35
35
from numpy .testing .decorators import slow
36
36
37
- from pandas ._parser import OverflowError
37
+ from pandas .parser import OverflowError
38
38
39
39
def _skip_if_no_xlrd ():
40
40
try :
@@ -275,12 +275,12 @@ def _check_extension(self, ext):
275
275
self .frame .to_excel (path , 'test1' )
276
276
recons = read_excel (path , 'test1' , index_col = 0 )
277
277
tm .assert_frame_equal (self .frame , recons )
278
-
278
+
279
279
self .frame .to_excel (path , 'test1' , index = False )
280
280
recons = read_excel (path , 'test1' , index_col = None )
281
281
recons .index = self .frame .index
282
282
tm .assert_frame_equal (self .frame , recons )
283
-
283
+
284
284
self .frame .to_excel (path , 'test1' , na_rep = 'NA' )
285
285
recons = read_excel (path , 'test1' , index_col = 0 , na_values = ['NA' ])
286
286
tm .assert_frame_equal (self .frame , recons )
@@ -346,7 +346,7 @@ def _check_extension_int64(self, ext):
346
346
self .frame .to_excel (path , 'test1' , cols = ['A' , 'B' ])
347
347
self .frame .to_excel (path , 'test1' , header = False )
348
348
self .frame .to_excel (path , 'test1' , index = False )
349
-
349
+
350
350
# Test np.int64, values read come back as float
351
351
frame = DataFrame (np .random .randint (- 10 , 10 , size = (10 , 2 )), dtype = np .int64 )
352
352
frame .to_excel (path , 'test1' )
@@ -372,7 +372,7 @@ def _check_extension_bool(self, ext):
372
372
self .frame .to_excel (path , 'test1' , cols = ['A' , 'B' ])
373
373
self .frame .to_excel (path , 'test1' , header = False )
374
374
self .frame .to_excel (path , 'test1' , index = False )
375
-
375
+
376
376
# Test reading/writing np.bool8, roundtrip only works for xlsx
377
377
frame = (DataFrame (np .random .randn (10 , 2 )) >= 0 )
378
378
frame .to_excel (path , 'test1' )
@@ -398,7 +398,7 @@ def _check_extension_sheets(self, ext):
398
398
self .frame .to_excel (path , 'test1' , cols = ['A' , 'B' ])
399
399
self .frame .to_excel (path , 'test1' , header = False )
400
400
self .frame .to_excel (path , 'test1' , index = False )
401
-
401
+
402
402
# Test writing to separate sheets
403
403
writer = ExcelWriter (path )
404
404
self .frame .to_excel (writer , 'test1' )
@@ -412,7 +412,7 @@ def _check_extension_sheets(self, ext):
412
412
np .testing .assert_equal (2 , len (reader .sheet_names ))
413
413
np .testing .assert_equal ('test1' , reader .sheet_names [0 ])
414
414
np .testing .assert_equal ('test2' , reader .sheet_names [1 ])
415
-
415
+
416
416
417
417
def test_excel_roundtrip_xls_colaliases (self ):
418
418
_skip_if_no_excelsuite ()
@@ -432,7 +432,7 @@ def _check_extension_colaliases(self, ext):
432
432
self .frame .to_excel (path , 'test1' , cols = ['A' , 'B' ])
433
433
self .frame .to_excel (path , 'test1' , header = False )
434
434
self .frame .to_excel (path , 'test1' , index = False )
435
-
435
+
436
436
# column aliases
437
437
col_aliases = Index (['AA' , 'X' , 'Y' , 'Z' ])
438
438
self .frame2 .to_excel (path , 'test1' , header = col_aliases )
@@ -441,7 +441,7 @@ def _check_extension_colaliases(self, ext):
441
441
xp = self .frame2 .copy ()
442
442
xp .columns = col_aliases
443
443
tm .assert_frame_equal (xp , rs )
444
-
444
+
445
445
def test_excel_roundtrip_xls_indexlabels (self ):
446
446
_skip_if_no_excelsuite ()
447
447
self ._check_extension_indexlabels ('xls' )
@@ -515,7 +515,7 @@ def test_excel_roundtrip_indexname(self):
515
515
516
516
xf = ExcelFile (path )
517
517
result = xf .parse (xf .sheet_names [0 ], index_col = 0 )
518
-
518
+
519
519
tm .assert_frame_equal (result , df )
520
520
self .assertEqual (result .index .name , 'foo' )
521
521
@@ -605,7 +605,7 @@ def _check_excel_multiindex_dates(self, ext):
605
605
tsframe .to_excel (path , 'test1' , index_label = ['time' , 'foo' ])
606
606
reader = ExcelFile (path )
607
607
recons = reader .parse ('test1' , index_col = [0 , 1 ])
608
-
608
+
609
609
tm .assert_frame_equal (tsframe , recons , check_names = False )
610
610
self .assertEquals (recons .index .names , ['time' , 'foo' ])
611
611
0 commit comments