Pandas DataFrame with tuple of strings as index
<p>I'm sensing some weird <code>pandas</code> behavior here. I have a dataframe that looks like</p>

<pre><code>df = pd.DataFrame(columns=['Col 1', 'Col 2', 'Col 3'],
                  index=[('1', 'a'), ('2', 'a'), ('1', 'b'), ('2', 'b')])

In [14]: df
Out[14]:
       Col 1 Col 2 Col 3
(1, a)   NaN   NaN   NaN
(2, a)   NaN   NaN   NaN
(1, b)   NaN   NaN   NaN
(2, b)   NaN   NaN   NaN
</code></pre>

<p>I can set the value of an arbitrary element</p>

<pre><code>In [15]: df['Col 2'].loc[('1', 'b')] = 6

In [16]: df
Out[16]:
       Col 1 Col 2 Col 3
(1, a)   NaN   NaN   NaN
(2, a)   NaN   NaN   NaN
(1, b)   NaN     6   NaN
(2, b)   NaN   NaN   NaN
</code></pre>

<p>But when I go to reference the element that I just set using the same syntax, I get</p>

<pre><code>In [17]: df['Col 2'].loc[('1', 'b')]
KeyError: 'the label [1] is not in the [index]'
</code></pre>

<p>Can someone tell me what I'm doing wrong or why this behavior occurs? Am I simply not allowed to set the index as a multi-element tuple?</p>

<p><strong>Edit</strong></p>

<p>Apparently, wrapping the tuple index in a list works.</p>

<pre><code>In [38]: df['Col 2'].loc[[('1', 'b')]]
Out[38]:
(1, b)    6
Name: Col 2, dtype: object
</code></pre>

<p>Although I'm still getting some weird behavior in my actual use case so it'd be nice to know if this is not recommended usage.</p>