title: Python pandas, Iterate through a data frame rows
body: <p>I want to iterate through rows of a dataframe, I have read this datafarame from an Excel file, and it has 3 columns, I tried to get data of each row and convert it to a dict then store it in a list.</p>
  <p>Dict format: <code>{&quot;subreddit_group&quot;: string, &quot;links/caption&quot;: list, &quot;Subreddits/flair&quot;: list}</code></p>
  <p>my code:</p>
  <pre><code>data_list = []
  linkcap_list = []
  subredditflair_list = []
  grp = &quot;&quot;
  data = pd.read_excel(&quot;data.xlsx&quot;)
  df = pd.DataFrame(data, columns=[&quot;subreddit_group&quot;, &quot;links/caption&quot;, &quot;subreddits/flair&quot;])
  data_raw = {}
  for index, row in df.iterrows():
      grp = row[&quot;subreddit_group&quot;]
      elms = row['links/caption'].split(&quot;,,&quot;)
      for elm in elms:
          elm_linkcap = {}
          try:
              link, cap = elm.split(&quot;^&quot;)
              elm_linkcap = {&quot;link&quot;: link, &quot;caption&quot;: cap}
              linkcap_list.append(elm_linkcap)
          except ValueError as e:
              elm_linkcap = {&quot;link&quot;: elm, &quot;caption&quot;: &quot;none&quot;}
              linkcap_list.append(elm_linkcap)
      elms = row['subreddits/flair'].split(&quot;,&quot;)
      for elm in elms:
          elm_subredditflair = {}
          try:
              subreddit, flair = elm.split(&quot;^&quot;)
              elm_subredditflair = {&quot;subreddit&quot;: subreddit, &quot;flair&quot;: flair}
              subredditflair_list.append(elm_subredditflair)
          except ValueError as e:
              elm_subredditflair = {&quot;subreddit&quot;: elm, &quot;flair&quot;: &quot;none&quot;}
              subredditflair_list.append(elm_subredditflair)
      data_raw = {&quot;group&quot;: grp, &quot;links_caps&quot;: linkcap_list, &quot;subreddits_flairs&quot;: subredditflair_list}
      data_list.append(data_raw)
  </code></pre>
  <p>I want to get the value of that column in each row, but every time I iterate through a row I get the value of the whole column I tried adding an index after the column name to access a specific cell, but I get a weird result, like this for example:</p>
  <pre><code>row['links/caption'][1]
  </code></pre>
  <p>how to iterate through a dataframe rows and access the value of each column, not the value of the whole column, I hope I was clear enough with my question, Thanks.
  edit1:
  using tuples.</p>
  <pre><code>data_list = []
  linkcap_list = []
  subredditflair_list = []
  grp = &quot;&quot;
  data = pd.read_excel(&quot;data.xlsx&quot;)
  df = pd.DataFrame(data, columns=[&quot;subreddit_group&quot;, &quot;links/caption&quot;, &quot;subreddits/flair&quot;])
  data_raw = {}
  for row in df.itertuples():
      print(row)
      grp = row[1]
      elms_linkscaps = row[2].split(&quot;,,&quot;)
      elms_subredditsflairs = row[3].split(&quot;,&quot;)
      print(elms_subredditsflairs)
      print(elms_linkscaps)
      exit()
      for elm in elms_linkscaps:
          elm_linkcap = {}
          try:
              link, cap = elm.split(&quot;^&quot;)
              elm_linkcap = {&quot;link&quot;: link, &quot;caption&quot;: cap}
              linkcap_list.append(elm_linkcap)
          except ValueError as e:
              elm_linkcap = {&quot;link&quot;: elm, &quot;caption&quot;: &quot;none&quot;}
              linkcap_list.append(elm_linkcap)
      for elm in elms_subredditsflairs:
          elm_subredditflair = {}
          try:
              subreddit, flair = elm.split(&quot;^&quot;)
              elm_subredditflair = {&quot;subreddit&quot;: subreddit, &quot;flair&quot;: flair}
              subredditflair_list.append(elm_subredditflair)
          except ValueError as e:
              elm_subredditflair = {&quot;subreddit&quot;: elm, &quot;flair&quot;: &quot;none&quot;}
              subredditflair_list.append(elm_subredditflair)
      data_raw = {&quot;group&quot;: grp, &quot;links_caps&quot;: linkcap_list, &quot;subreddits_flairs&quot;: subredditflair_list}
      data_list.append(data_raw)
  </code></pre>