Repository: pandas-dev/pandas

Issue:
Pandas Panel doesn't support getting DataFrame or (sub) Panel using a list of index
Hello,

when I try to get a DataFrame (or sub Panel) from a Panel using index as list it raises the following error:

```
TypeError: unhashable type: 'list'
```

See the code

```
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pandas as pd
import pandas.io.data as web

start = "2010-01-01"
end = "2010-01-30"

df = web.DataReader("AAPL", 'yahoo', start, end)

print("DF 1")
data = df[['Open', 'Close']] # returns pandas.core.frame.DataFrame
print(data)
print(type(data))

print("DF 2")
data = df['Open'] # returns pandas.core.series.Series
print(data)
print(type(data))

print("DF 3")
data = df[['Open']] # returns pandas.core.frame.DataFrame
print(data)
print(type(data))

panel = web.DataReader(["AAPL", "GOOGL"], 'yahoo', start, end)
#Items axis: Open to Adj Close
#Major_axis axis: 2010-01-04 00:00:00 to 2010-01-29 00:00:00
#Minor_axis axis: AAPL to GOOGL
panel = panel.transpose(2, 1, 0) # symbol is panel index
#Items axis: AAPL to GOOGL
#Major_axis axis: 2010-01-04 00:00:00 to 2010-01-29 00:00:00
#Minor_axis axis: Open to Adj Close
print(panel)

print("P 1")
data = panel["AAPL"] # returns pandas.core.frame.DataFrame
print(data)
print(type(data))

print("P 2")
#data = panel[["AAPL"]] # Error: Should return a DataFrame but raises TypeError: unhashable type: 'list'
#print(data)    
#print(type(data))

print("P 3")
#data = panel[["AAPL", "GOOGL"]] # Error: Should return a "sub" Panel but raises TypeError: unhashable type: 'list'

#print(data)
#print(type(data))
```

But that can be a misunderstanding on my side.

Thanks



Discussion:
pd.show_versions() pls

```
pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Darwin
OS-release: 11.4.2
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8

pandas: 0.15.0
nose: 1.3.4
Cython: 0.21
numpy: 1.8.1
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.2.0
sphinx: 1.2.3
patsy: 0.3.0
dateutil: 2.2
pytz: 2014.7
bottleneck: None
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.4.0
openpyxl: 2.0.3
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.7
lxml: 3.3.6
bs4: 4.3.2
html5lib: 0.999
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.7
pymysql: None
psycopg2: None  
```

hmm, it does look buggy

this is the general access method (note that this is with 0.15.1/master). A couple of indexing bugs were fixed in in 0.15.0 so worthile to upgrade.

```
In [18]: panel.loc[:,:,['AAPL','GOOGL']]
Out[18]: 
<class 'pandas.core.panel.Panel'>
Dimensions: 6 (items) x 19 (major_axis) x 2 (minor_axis)
Items axis: Open to Adj Close
Major_axis axis: 2010-01-04 00:00:00 to 2010-01-29 00:00:00
Minor_axis axis: AAPL to GOOGL
```


Resolving patch:
diff --git a/pandas/core/panel.py b/pandas/core/panel.py
--- a/pandas/core/panel.py
+++ b/pandas/core/panel.py
@@ -29,7 +29,7 @@
 import pandas.core.ops as ops
 import pandas.core.nanops as nanops
 import pandas.computation.expressions as expressions
-
+from pandas import lib
 
 _shared_doc_kwargs = dict(
     axes='items, major_axis, minor_axis',
@@ -253,7 +253,9 @@ def from_dict(cls, data, intersect=False, orient='items', dtype=None):
     def __getitem__(self, key):
         if isinstance(self._info_axis, MultiIndex):
             return self._getitem_multilevel(key)
-        return super(Panel, self).__getitem__(key)
+        if lib.isscalar(key):
+            return super(Panel, self).__getitem__(key)
+        return self.ix[key]
 
     def _getitem_multilevel(self, key):
         info = self._info_axis


Test patch:
diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py
--- a/pandas/tests/test_indexing.py
+++ b/pandas/tests/test_indexing.py
@@ -2325,6 +2325,30 @@ def test_panel_getitem(self):
         test1 = panel.ix[:, "2002"]
         tm.assert_panel_equal(test1,test2)
 
+        # GH8710
+        # multi-element getting with a list
+        panel = tm.makePanel()
+
+        expected = panel.iloc[[0,1]]
+
+        result = panel.loc[['ItemA','ItemB']]
+        tm.assert_panel_equal(result,expected)
+
+        result = panel.loc[['ItemA','ItemB'],:,:]
+        tm.assert_panel_equal(result,expected)
+
+        result = panel[['ItemA','ItemB']]
+        tm.assert_panel_equal(result,expected)
+
+        result = panel.loc['ItemA':'ItemB']
+        tm.assert_panel_equal(result,expected)
+
+        result = panel.ix['ItemA':'ItemB']
+        tm.assert_panel_equal(result,expected)
+
+        result = panel.ix[['ItemA','ItemB']]
+        tm.assert_panel_equal(result,expected)
+
     def test_panel_setitem(self):
 
         # GH 7763