Repository: pandas-dev/pandas

Issue:
ENH: Default for Excel sheetname
Excel workbooks have 'Sheet1' as the default sheet. Can `pd.read_excel` have this as a default? `pandas.io.excel.read_excel(io, sheetname='Sheet1', **kwds)`

This makes pandas more accessible to the user transitioning from Excel by avoiding the common error below:

```
In [9]: test = pd.read_excel('/Users/clark/Desktop/test.xlsx')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-14880f6f18e4> in <module>()
----> 1 test = pd.read_excel('/Users/clark/Desktop/test.xlsx')

TypeError: read_excel() takes exactly 2 arguments (1 given)
```



Discussion:
hmm...seems reasonable...PR for this?

Sure, I'll submit a PR tonight.

Probably the default should be 0 (I _think_ these can be accessed by number rather than name now?)

yep that is right!

Then the first sheet will be loaded even if it doesn't have the name 'Sheet1'. Smart.


Resolving patch:
diff --git a/pandas/io/excel.py b/pandas/io/excel.py
--- a/pandas/io/excel.py
+++ b/pandas/io/excel.py
@@ -49,17 +49,17 @@ def get_writer(engine_name):
         raise ValueError("No Excel writer '%s'" % engine_name)
 
 
-def read_excel(io, sheetname, **kwds):
+def read_excel(io, sheetname=0, **kwds):
     """Read an Excel table into a pandas DataFrame
 
     Parameters
     ----------
     io : string, file-like object or xlrd workbook
         If a string, expected to be a path to xls or xlsx file
-    sheetname : string
-         Name of Excel sheet
+    sheetname : string or int, default 0
+        Name of Excel sheet or the page number of the sheet
     header : int, default 0
-         Row to use for the column labels of the parsed DataFrame
+        Row to use for the column labels of the parsed DataFrame
     skiprows : list-like
         Rows to skip at the beginning (0-indexed)
     skip_footer : int, default 0
@@ -147,7 +147,7 @@ def __init__(self, io, **kwds):
             raise ValueError('Must explicitly set engine if not passing in'
                              ' buffer or path for io.')
 
-    def parse(self, sheetname, header=0, skiprows=None, skip_footer=0,
+    def parse(self, sheetname=0, header=0, skiprows=None, skip_footer=0,
               index_col=None, parse_cols=None, parse_dates=False,
               date_parser=None, na_values=None, thousands=None, chunksize=None,
               convert_float=True, has_index_names=False, **kwds):
@@ -200,7 +200,8 @@ def parse(self, sheetname, header=0, skiprows=None, skip_footer=0,
         if skipfooter is not None:
             skip_footer = skipfooter
 
-        return self._parse_excel(sheetname, header=header, skiprows=skiprows,
+        return self._parse_excel(sheetname=sheetname, header=header,
+                                 skiprows=skiprows,
                                  index_col=index_col,
                                  has_index_names=has_index_names,
                                  parse_cols=parse_cols,
@@ -244,7 +245,7 @@ def _excel2num(x):
         else:
             return i in parse_cols
 
-    def _parse_excel(self, sheetname, header=0, skiprows=None, skip_footer=0,
+    def _parse_excel(self, sheetname=0, 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, convert_float=True,


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
@@ -445,6 +445,15 @@ def test_roundtrip(self):
                                 na_values=[88, 88.0])
             tm.assert_frame_equal(self.frame, recons)
 
+            # GH 6573
+            self.frame.to_excel(path, 'Sheet1')
+            recons = read_excel(path, index_col=0)
+            tm.assert_frame_equal(self.frame, recons)
+
+            self.frame.to_excel(path, '0')
+            recons = read_excel(path, index_col=0)
+            tm.assert_frame_equal(self.frame, recons)
+
     def test_mixed(self):
         _skip_if_no_xlrd()