File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -120,9 +120,17 @@ def _parse_cell(cell_contents, cell_typ):
120
120
elif cell_typ == XL_CELL_NUMBER :
121
121
# GH5394 - Excel 'numbers' are always floats
122
122
# it's a minimal perf hit and less surprising
123
- val = int (cell_contents )
124
- if val == cell_contents :
125
- cell_contents = val
123
+ try :
124
+ val = int (cell_contents )
125
+ except Exception :
126
+ # GH54564 - if the cell contents are NaN/Inf, we get an exception;
127
+ # that is just another case where we don't want to convert.
128
+ # The exception filter is quite general on purpose: whenever
129
+ # the cell content cannot be converted to int - just don't.
130
+ pass
131
+ else :
132
+ if val == cell_contents :
133
+ cell_contents = val
126
134
return cell_contents
127
135
128
136
data = []
Original file line number Diff line number Diff line change @@ -49,9 +49,9 @@ def test_nan_in_xls(datapath):
49
49
# GH 54564
50
50
path = datapath ("io" , "data" , "excel" , "test6.xls" )
51
51
52
- expected = pd .DataFrame (np .r_ [:3 , np .nan ].reshape (2 , 2 ))
52
+ expected = pd .DataFrame (np .r_ [:3 , np .nan ].reshape (2 , 2 )). astype ( float )
53
53
54
- result = pd .read_excel (path )
54
+ result = pd .read_excel (path , header = None ). astype ( float )
55
55
56
56
tm .assert_frame_equal (result , expected )
57
57
You can’t perform that action at this time.
0 commit comments