Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pandas/io/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def parse(self, sheetname, header=0, skiprows=None, skip_footer=0,
na_values=na_values,
thousands=thousands,
chunksize=chunksize,
skip_footer=skip_footer)
skip_footer=skip_footer,
**kwds)

def _should_parse(self, i, parse_cols):

Expand Down Expand Up @@ -163,7 +164,8 @@ def _excel2num(x):
def _parse_excel(self, sheetname, header=0, skiprows=None,
skip_footer=0, index_col=None, has_index_names=None,
parse_cols=None, parse_dates=False, date_parser=None,
na_values=None, thousands=None, chunksize=None):
na_values=None, thousands=None, chunksize=None,
**kwds):
from xlrd import (xldate_as_tuple, XL_CELL_DATE,
XL_CELL_ERROR, XL_CELL_BOOLEAN)

Expand Down Expand Up @@ -206,7 +208,8 @@ def _parse_excel(self, sheetname, header=0, skiprows=None,
date_parser=date_parser,
skiprows=skiprows,
skip_footer=skip_footer,
chunksize=chunksize)
chunksize=chunksize,
**kwds)

return parser.read()

Expand Down
Binary file added pandas/io/tests/data/test2.xlsx
Binary file not shown.
16 changes: 16 additions & 0 deletions pandas/io/tests/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ def test_excel_cell_error_na(self):
expected = DataFrame([[np.nan]], columns=['Test'])
tm.assert_frame_equal(parsed, expected)

def test_excel_passes_na(self):
_skip_if_no_xlrd()

excel_data = ExcelFile(os.path.join(self.dirpath, 'test2.xlsx'))
parsed = excel_data.parse('Sheet1', keep_default_na=False,
na_values=['apple'])
expected = DataFrame([['NA'], [1], ['NA'], [np.nan], ['rabbit']],
columns=['Test'])
tm.assert_frame_equal(parsed, expected)

parsed = excel_data.parse('Sheet1', keep_default_na=True,
na_values=['apple'])
expected = DataFrame([[np.nan], [1], [np.nan], [np.nan], ['rabbit']],
columns=['Test'])
tm.assert_frame_equal(parsed, expected)

def test_excel_table(self):
_skip_if_no_xlrd()

Expand Down