title: How to look for a value in a specific pandas data frame column and then store the other values from that row in separate variables
body: <p>I am trying to automatically send emails based on values found in a csv file that I am reading into a pandas data frame.  I want to figure out how to look for a specific word in a column from the pandas data frame, and when that word appears, I then want to return the other values from that row in separate variables to be used later in the email function (def send_notification).  I have found some methods to return all the variables from a row as one list or string, but I cannot figure out how to store them in separate variables.</p>
  
  <p>The other part that is hanging me up is that I need this to all happen in an iterative fashion.  Since I am trying to use these variables to fill in data in another function (def send_notification) that sends out emails to people, I need the function that stores the data into separate variable to iterate over the data frame, and trigger the email functions (call def check_outlook) for each instance of the trigger word (reasona) in the data frame.  I am not sure how to do this either with pandas.</p>
  
  <p>my csv file will contain something like this:</p>
  
  <pre><code>reasons    notes     email
  reasona    notea     namea@email.org
  reasonb    noteb     nameb@email.org
  reasonc    notec     namec@email.org
  </code></pre>
  
  <p>The part of the code that I can't figure out right now is this:</p>
  
  <pre><code>def get_email_data():
      for i in dt:
              if i == "reasona":
  
                  # getname = value from column email from row containing key word in dataframe
                  # getnotes = will be value from column notes from row containing key word in dataframe.  To be used in email body.
                  # get reasons = value from column reasons row containing key word in dataframe. To be used in email body.              
                  #Call check_outlook() at the end of this function to trigger email
  </code></pre>
  
  <p>Here is my idea so far for the whole script.  If there is a better way to go about this, any input is greatly appreciate.</p>
  
  <pre><code>import win32com.client as win32
  import psutil
  import os
  import subprocess
  import pandas as pd
  
  filename = "users\\cmbp\\p4e\\test_rad_reports.csv"
  my_csv = pd.read_csv(filename)
  dt = pd.read_csv(filename, usecols=['reason', 'notes', 'email'])
  
  def get_email_data():
      for i in dt:
          if i == "reasona":
  
              # getname = value from row containing key word in dataframe
              # getsubject = value from row containing key word in dataframe
              # getbody = value from row containing key word in dataframe
              #call mak_address() at end of capturing values from pandas dataframe
              #Call check_outlook() at the end of this function to trigger email
  
  
          # Drafting and sending email notification to senders. 
  
          def send_notification():
              outlook = win32.Dispatch('outlook.application')
              mail = outlook.CreateItem(0)
              mail.To = getname
              mail.Subject = "This is a generic subject to all emails"
              mail.body = getreasons + getnotes
  
              i = 0
              for i
  
              mail.send
  
          # Open Outlook.exe. Path may vary according to system config
          # Please check the path to .exe file and update below
  
          def open_outlook():
              try:
                  subprocess.call(['C:\Program Files\Microsoft Office\Office16\Outlook.exe'])
                  os.system("C:\Program Files\Microsoft Office\Office16\Outlook.exe");
              except:
                  print("Outlook didn't open successfully")
  
          # Checking if outlook is already opened. If not, open Outlook.exe and send email
  
          def check_outlook():
              for item in psutil.pids():
                  p = psutil.Process(item)
                  if p.name() == "OUTLOOK.EXE":
                      flag = 1
                      break
                  else:
                      flag = 0
  
              if (flag == 1):
                  send_notification()
              else:
                  open_outlook()
                  send_notification()
  </code></pre>