title: Get specific column after iterating over each row of pandas dataframe
body: <p>As a first step, I want to plot the regression on time for each gene taking all the variables present in the model, hence using all the genes, was performed. In <code>df5</code>, the columns represent time and rows represent gene expression.</p>
  <pre><code>fig = px.scatter(df5, x='0', y='prediction',marginal_x='histogram', marginal_y='histogram',color='split', trendline='ols')
  </code></pre>
  <p>However, now I want to get the first column of each row after iterating over the rows of a pandas dataframe. My code raised <code>IndexingError: Too many indexers</code> error.</p>
  <pre><code>import pandas as pd
  import plotly.graph_objects as go
  import numpy as np
  import plotly.express as px
  from sklearn.linear_model import LinearRegression
  from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_error
  from sklearn.feature_selection import SelectFdr, chi2
  from sklearn.model_selection import train_test_split, cross_val_score
  from sklearn.preprocessing import OneHotEncoder, MinMaxScaler
  
  # Split data into training and test splits
  train_idx, test_idx = train_test_split(df5.index, test_size=.25, random_state=0)
  df5[&quot;split&quot;] = &quot;train&quot;
  df5.loc[test_idx, &quot;split&quot;] = &quot;test&quot;
  
  # Inputs and targets
  X = df5.iloc[:, 1:-1]
  y = df5.iloc[:, 0]
  
  X_train = df5.loc[train_idx, [&quot;4&quot;, &quot;8&quot;, &quot;12&quot;, &quot;24&quot;, &quot;48&quot;]]
  y_train = df5.loc[train_idx, &quot;0&quot;]
  
  # Linear regression prediction
  model = LinearRegression()
  model.fit(X_train, y_train)
  df5['prediction'] = model.predict(X)
  </code></pre>
  <p>Now, I want to plot the regression on time for each gene.</p>
  <pre><code># Scatter plot 
  for i, j in df5.iterrows():
    fig = px.scatter(j, x=j.iloc[:,0], y=j['prediction'],marginal_x='histogram', marginal_y='histogram',color='split', trendline='ols')
    fig.update_traces(histnorm='probability', selector={'type':'histogram'})
    fig.add_shape(type=&quot;line&quot;, line=dict(dash='dash'),x0=y.min(), y0=y.min(),x1=y.max(), y1=y.max())
    fig.show()
  </code></pre>
  <p>Traceback:</p>
  <pre><code>---------------------------------------------------------------------------
  IndexingError                             Traceback (most recent call last)
  &lt;ipython-input-342-7353b9534134&gt; in &lt;module&gt;()
        1 # Scatter plot
        2 for i, j in df5.iterrows():
  ----&gt; 3   fig = px.scatter(j, x=j.iloc[:,0], y=j['prediction'],marginal_x='histogram', marginal_y='histogram',color='split', trendline='ols')
        4   fig.update_traces(histnorm='probability', selector={'type':'histogram'})
        5   fig.add_shape(type=&quot;line&quot;, line=dict(dash='dash'),x0=y.min(), y0=y.min(),x1=y.max(), y1=y.max())
  
  3 frames
  /usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in __getitem__(self, key)
      923                 with suppress(KeyError, IndexError):
      924                     return self.obj._get_value(*key, takeable=self._takeable)
  --&gt; 925             return self._getitem_tuple(key)
      926         else:
      927             # we by definition only have the 0th axis
  
  /usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in _getitem_tuple(self, tup)
     1504     def _getitem_tuple(self, tup: tuple):
     1505 
  -&gt; 1506         self._has_valid_tuple(tup)
     1507         with suppress(IndexingError):
     1508             return self._getitem_lowerdim(tup)
  
  /usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in _has_valid_tuple(self, key)
      749         Check the key for valid keys across my indexer.
      750         &quot;&quot;&quot;
  --&gt; 751         self._validate_key_length(key)
      752         for i, k in enumerate(key):
      753             try:
  
  /usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py in _validate_key_length(self, key)
      790     def _validate_key_length(self, key: Sequence[Any]) -&gt; None:
      791         if len(key) &gt; self.ndim:
  --&gt; 792             raise IndexingError(&quot;Too many indexers&quot;)
      793 
      794     def _getitem_tuple_same_dim(self, tup: tuple):
  
  IndexingError: Too many indexers
  </code></pre>
  <p>Data:</p>
  <p><code>df5.head().to_dict()</code></p>
  <pre><code>{'0': {'DNAJB6 /// TMEM135': 0.30131649339447103,
    'DNAJC14': 0.2255444383216058,
    'DNAJC15': 0.25789169794229455,
    'DNAJC30': 0.11388797858763917,
    'DNAJC9': 0.11205541676885071},
   '12': {'DNAJB6 /// TMEM135': 0.28354614480145346,
    'DNAJC14': 0.2343653660720247,
    'DNAJC15': 0.2406210529534205,
    'DNAJC30': 0.11229754447748205,
    'DNAJC9': 0.12045170255898871},
   '24': {'DNAJB6 /// TMEM135': 0.27395808285292367,
    'DNAJC14': 0.2246018336027369,
    'DNAJC15': 0.22347959865906092,
    'DNAJC30': 0.11379897713291527,
    'DNAJC9': 0.10622530623273815},
   '4': {'DNAJB6 /// TMEM135': 0.2949284643966144,
    'DNAJC14': 0.22905481299223704,
    'DNAJC15': 0.22312009403152122,
    'DNAJC30': 0.13114878202076288,
    'DNAJC9': 0.12991396178392187},
   '48': {'DNAJB6 /// TMEM135': 0.289873135093664,
    'DNAJC14': 0.2349502215468218,
    'DNAJC15': 0.17706771640592167,
    'DNAJC30': 0.10857074282633467,
    'DNAJC9': 0.13001391250069522},
   '8': {'DNAJB6 /// TMEM135': 0.2794865791356734,
    'DNAJC14': 0.22228815371920396,
    'DNAJC15': 0.22912018863353348,
    'DNAJC30': 0.11799998627920205,
    'DNAJC9': 0.10520854728987451},
   'prediction': {'DNAJB6 /// TMEM135': 0.2855688204171829,
    'DNAJC14': 0.22191146957280725,
    'DNAJC15': 0.24908287098429563,
    'DNAJC30': 0.12514969134896878,
    'DNAJC9': 0.11705504942609991},
   'split': {'DNAJB6 /// TMEM135': 'test',
    'DNAJC14': 'test',
    'DNAJC15': 'train',
    'DNAJC30': 'train',
    'DNAJC9': 'train'}}
  </code></pre>