title: Lambda and eval doesn't working inside a function
body: <p>I am a newbie to python and I will really appreciate your help in my following problem.</p>
  <p>Problem:</p>
  <p>I am working a keyword matching on a Dataframe, I did try the code in Jupyter notebook where it is working perfectly fine. However, the same code is not working in Visual Code. Both Jupyter Notebook and VS Code are running on the same python environment.</p>
  <p>Input Dataframe:</p>
  <pre><code>note
  -----------------
  I have a kayak
  I have a jet-ski
  I have a canoe
  I have a jetski
  </code></pre>
  <p>Code that does the magic:</p>
  <pre><code>def extract():
      keywords = ['kayak','jetski']
  
      kayak = re.compile(r'.*(pin.pad|pinpad).*')
      jetski= re.compile(r'.*(jetski|jet.ski).*')
  
      for i in keywords:
          df[i] = df['note'].apply(lambda x: bool(eval((i)).match(x)))
  
  </code></pre>
  <p>I did receive the expected output in Jupyter however, Visual Code states the following error.</p>
  <pre><code>File &quot;xyz.py&quot;, line 8, in &lt;lambda&gt;
      df[i] = df['note'].apply(lambda x: bool(eval((i)).match(x)))
    File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
  NameError: name 'kayak' is not defined
  </code></pre>
  <p>Expected Output:</p>
  <pre><code>note                  kayak       jetski
  -----------------------------------------
  I have a kayak         True        False
  I have a jet-ski       False       True
  I have a canoe         False       False
  I have a jetski        False       True
  </code></pre>
  <p>Please let me know if this has already been answered or if further information is required. :)</p>