Repository: pandas-dev/pandas

Issue:
Allow true_values and false_values options in read_excel
For consistency with read_csv, and because this would be handy anyway.



Discussion:
ok, sure, want to do a pull-request?


Resolving patch:
diff --git a/pandas/io/excel.py b/pandas/io/excel.py
--- a/pandas/io/excel.py
+++ b/pandas/io/excel.py
@@ -86,6 +86,16 @@
     either be integers or column labels, values are functions that take one
     input argument, the Excel cell content, and return the transformed
     content.
+true_values : list, default None
+    Values to consider as True
+
+    .. versionadded:: 0.19.0
+
+false_values : list, default None
+    Values to consider as False
+
+    .. versionadded:: 0.19.0
+
 parse_cols : int or list, default None
     * If None then parse all columns,
     * If int then indicates last column to be parsed
@@ -173,7 +183,8 @@ def read_excel(io, sheetname=0, header=0, skiprows=None, skip_footer=0,
                index_col=None, names=None, parse_cols=None, parse_dates=False,
                date_parser=None, na_values=None, thousands=None,
                convert_float=True, has_index_names=None, converters=None,
-               engine=None, squeeze=False, **kwds):
+               true_values=None, false_values=None, engine=None, squeeze=False,
+               **kwds):
 
     if not isinstance(io, ExcelFile):
         io = ExcelFile(io, engine=engine)
@@ -184,7 +195,8 @@ def read_excel(io, sheetname=0, header=0, skiprows=None, skip_footer=0,
         date_parser=date_parser, na_values=na_values, thousands=thousands,
         convert_float=convert_float, has_index_names=has_index_names,
         skip_footer=skip_footer, converters=converters,
-        squeeze=squeeze, **kwds)
+        true_values=true_values, false_values=false_values, squeeze=squeeze,
+        **kwds)
 
 
 class ExcelFile(object):
@@ -242,7 +254,8 @@ def parse(self, sheetname=0, header=0, skiprows=None, skip_footer=0,
               names=None, index_col=None, parse_cols=None, parse_dates=False,
               date_parser=None, na_values=None, thousands=None,
               convert_float=True, has_index_names=None,
-              converters=None, squeeze=False, **kwds):
+              converters=None, true_values=None, false_values=None,
+              squeeze=False, **kwds):
         """
         Parse specified sheet(s) into a DataFrame
 
@@ -261,6 +274,8 @@ def parse(self, sheetname=0, header=0, skiprows=None, skip_footer=0,
                                  skip_footer=skip_footer,
                                  convert_float=convert_float,
                                  converters=converters,
+                                 true_values=true_values,
+                                 false_values=false_values,
                                  squeeze=squeeze,
                                  **kwds)
 
@@ -301,7 +316,8 @@ def _parse_excel(self, sheetname=0, header=0, skiprows=None, names=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, convert_float=True,
-                     verbose=False, squeeze=False, **kwds):
+                     true_values=None, false_values=None, verbose=False,
+                     squeeze=False, **kwds):
 
         skipfooter = kwds.pop('skipfooter', None)
         if skipfooter is not None:
@@ -479,6 +495,8 @@ def _parse_cell(cell_contents, cell_typ):
                                     thousands=thousands,
                                     parse_dates=parse_dates,
                                     date_parser=date_parser,
+                                    true_values=true_values,
+                                    false_values=false_values,
                                     skiprows=skiprows,
                                     skipfooter=skip_footer,
                                     squeeze=squeeze,


Test patch:
diff --git a/pandas/io/tests/test_excel.py b/pandas/io/tests/test_excel.py
--- a/pandas/io/tests/test_excel.py
+++ b/pandas/io/tests/test_excel.py
@@ -1781,6 +1781,17 @@ def test_write_lists_dict(self):
             read = read_excel(path, 'Sheet1', header=0)
             tm.assert_frame_equal(read, expected)
 
+    # GH13347
+    def test_true_and_false_value_options(self):
+        df = pd.DataFrame([['foo', 'bar']], columns=['col1', 'col2'])
+        expected = df.replace({'foo': True,
+                               'bar': False})
+        with ensure_clean(self.ext) as path:
+            df.to_excel(path)
+            read_frame = read_excel(path, true_values=['foo'],
+                                    false_values=['bar'])
+            tm.assert_frame_equal(read_frame, expected)
+
 
 def raise_wrapper(major_ver):
     def versioned_raise_wrapper(orig_method):