Calling a subset of a dataset
<pre><code>x_train = train['date_x','activity_category','char_1_x','char_2_x','char_3_x','char_4_x','char_5_x','char_6_x',
'char_7_x','char_8_x','char_9_x','char_10_x',.........,'char_27','char_29','char_30','char_31','char_32','char_33',
'char_34','char_35','char_36','char_37','char_38']
y = y_train
x_test = test['date_x','activity_category','char_1_x','char_2_x','char_3_x','char_4_x','char_5_x','char_6_x',
'char_7_x','char_8_x','char_9_x','char_10_x','char_1_y','group_1','char_1_y','char_2_y','char_3_y', 'char_4_y','char_5_y','char_6_y','char_7_y',
'char_8_y','char_9-y','char_10_y', ...........,'char_29','char_30','char_31','char_32','char_33',
'char_34','char_35','char_36','char_37','char_38']

train.iloc([0:17,19:38])
</code></pre>

<p>After trying to slice columns with <code>train([0:17,19:38)]</code>, I resorted to data entry of all column names. A pretty cumbersome way of doing this, but I am only getting what I call with <code>19:38</code>. I am getting Key error message for doing it the first way, by calling the column names. </p>

<p>As suggested by @AndrasDeak<br>
Consider the <code>pd.DataFrame</code> <code>train</code></p>

<pre><code>train = pd.DataFrame(np.arange(1000).reshape(-1, 20))
</code></pre>

<p>Then use the suggestion like this</p>

<pre><code>train.iloc[np.r_[0:17, 19:38]]
</code></pre>

python pandas