Why df[[2,3,4]][2:4] works and df[[2:4]][2:4] does not in Python
<p>suppose we have a datarame</p>

<pre><code>import pandas as pd
df = pd.read_csv('...')
df
  0 1 2 3 4
0 1 2 3 4 5
1 1 2 3 4 5
2 1 2 3 4 5
3 1 2 3 4 5
4 1 2 3 4 5
</code></pre>

<p>Why one approach is working and other returns syntax error?</p>

<p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.ix.html" rel="nofollow"><code>ix</code></a>:</p>

<pre><code>print (df.ix[2:4,2:4])
   2  3
2  3  4
3  3  4
4  3  4
</code></pre>

python pandas dataframe subset