title: python giving "IndexError: single positional indexer is out-of-bounds"
body: <p>Below is the code that I used:</p>
  
  <pre><code>#Divide data into train and test
  p_dt_train, p_dt_test = train_test_split(p_main_df, test_size=0.2)
  
  #Shape #(3485868, 26)
  p_dt_train.shape
  
  p_fit_DT = DecisionTreeRegressor(max_depth=2).fit(p_dt_train.iloc[:,0:26], p_dt_train.iloc[:,26])
  </code></pre>
  
  <hr>
  
  <p>But when I am running the above line of of code aka <code>p_fit_DT</code>, the following error occurs:</p>
  
  <pre><code>IndexError                                Traceback (most recent call last)
  &lt;ipython-input-59-9bbf02d21cd5&gt; in &lt;module&gt;()
        1 # In[1]:
        2 #Decision tree for regression
  ----&gt; 3 p_fit_DT = DecisionTreeRegressor(max_depth=2).fit(p_dt_train.iloc[:,0:26], p_dt_train.iloc[:,26])
        4 
        5 #Apply model on test data
  
  D:\My_Work\anaconda3\lib\site-packages\pandas\core\indexing.py in __getitem__(self, key)
     1470             except (KeyError, IndexError):
     1471                 pass
  -&gt; 1472             return self._getitem_tuple(key)
     1473         else:
     1474             # we by definition only have the 0th axis
  
  D:\My_Work\anaconda3\lib\site-packages\pandas\core\indexing.py in _getitem_tuple(self, tup)
     2011     def _getitem_tuple(self, tup):
     2012 
  -&gt; 2013         self._has_valid_tuple(tup)
     2014         try:
     2015             return self._getitem_lowerdim(tup)
  
  D:\My_Work\anaconda3\lib\site-packages\pandas\core\indexing.py in _has_valid_tuple(self, key)
      220                 raise IndexingError('Too many indexers')
      221             try:
  --&gt; 222                 self._validate_key(k, i)
      223             except ValueError:
      224                 raise ValueError("Location based indexing can only have "
  
  D:\My_Work\anaconda3\lib\site-packages\pandas\core\indexing.py in _validate_key(self, key, axis)
     1955             return
     1956         elif is_integer(key):
  -&gt; 1957             self._validate_integer(key, axis)
     1958         elif isinstance(key, tuple):
     1959             # a tuple should already have been caught by this point
  
  D:\My_Work\anaconda3\lib\site-packages\pandas\core\indexing.py in _validate_integer(self, key, axis)
     2007         l = len(ax)
     2008         if key &gt;= l or key &lt; -l:
  -&gt; 2009             raise IndexError("single positional indexer is out-of-bounds")
     2010 
     2011     def _getitem_tuple(self, tup):
  
  IndexError: single positional indexer is out-of-bounds
  </code></pre>
  
  <p>Please guide me as where I am going wrong.
  Thanks in advance.</p>