From caf507e2d8fba694ccaa0adbfd8ebcd4ffb259eb Mon Sep 17 00:00:00 2001 From: hunterowens Date: Thu, 1 Jan 2015 17:13:32 -0800 Subject: [PATCH 1/2] adding is_list_like check for excel, #8188 --- pandas/io/excel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 2ece91b5dea11..4355d65718765 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -401,7 +401,8 @@ def _conv_value(val): val = bool(val) elif isinstance(val, Period): val = "%s" % val - + elif com.is_list_like(val): + val = str(val) return val From bb468f86d57f4eb0e65d75c3161d9e3209ea2c05 Mon Sep 17 00:00:00 2001 From: hunterowens Date: Thu, 1 Jan 2015 17:22:25 -0800 Subject: [PATCH 2/2] test is_list_like, #8188 --- pandas/io/tests/test_excel.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/io/tests/test_excel.py b/pandas/io/tests/test_excel.py index 4f97cef3d46d3..4c1d58de8aa8b 100644 --- a/pandas/io/tests/test_excel.py +++ b/pandas/io/tests/test_excel.py @@ -930,6 +930,17 @@ def test_to_excel_float_format(self): index=['A', 'B'], columns=['X', 'Y', 'Z']) tm.assert_frame_equal(rs, xp) + def test_to_excel_list_format(self): + _skip_if_no_xlrd() + + df = DataFrame([0.0, ['0.0',0.0]], + columns=['not_list','list']) + + with ensure_clean(self.ext) as filename: + df.to_excel(filename, sheetname='TestList') + result = read_excel(filename,'TestList') + tm.assert_equal(result,df) + def test_to_excel_output_encoding(self): _skip_if_no_xlrd() ext = self.ext