title: get pandas value by another file python pandas
body: <p>I have a small sample dataset:</p>
  
  <pre><code>import pandas as pd
  
  df = {'ID': ['H576','H577','H578','H600', 'H700'],
    'CD': ['AAAAAAA', 'BBBBB', 'CCCCCC','DDDDDD', 'EEEEEEE']}
  
  df = pd.DataFrame(df)
  </code></pre>
  
  <p>it looks like:</p>
  
  <pre><code>Out[76]: 
      CD    ID
  0  AAAAAAA  H576
  1    BBBBB  H577
  2   CCCCCC  H578
  3   DDDDDD  H600
  4  EEEEEEE  H700
  </code></pre>
  
  <p>i also have a small .txt file :</p>
  
  <pre><code>AAAAAAA
  BBBBB
  EEEEEEE
  </code></pre>
  
  <p>I want to loop through the 'CD' column from the dataframe and the .txt file, if there is a match, print out the ID and the CD in a .txt file.</p>
  
  <p>desire output, output.txt: </p>
  
  <pre><code>H576
  AAAAAAA
  H577
  BBBBB
  H700
  EEEEEEE
  </code></pre>
  
  <p>my attempt:</p>
  
  <pre><code>import pandas as pd
  
  
  df = {'ID': ['H576','H577','H578','H600', 'H700'],
    'CD': ['AAAAAAA', 'BBBBB', 'CCCCCC','DDDDDD', 'EEEEEEE']}
  
  
  df = pd.DataFrame(df)
  f = open('file.txt') 
  
  for i in data.CD:
      i = i.strip()    
      for line in f:
          line = line.strip()
  
          if df["CD"].str.contains(line).any():
              position = df.index.get_indexer_for((df[df["CD"].str.contains(line)].index))
              z = df.ReadID[position]
              print(z)
              print(line)
  </code></pre>
  
  <p>this is not quite right and i think i might be over thinking this. </p>