title: Exec function won't work in Python with a pandas dataframe
body: <p>I have an initial dataframe called <code>source_data</code>.</p>
  
  <p>I have a separate text file which allows a user to place some python code in for some filter criteria. I know this is seen as bad practice, but my company has assured me that it's safe to do. I've noted my concerns but I have the green light.</p>
  
  <p>So, this CSV has this string in a cell: <code>source_data.loc[source_data['CONFIG_ID'] == 3]</code></p>
  
  <p>This is read in as a list. As an example, here's two prints:</p>
  
  <pre><code>print('Number of where clause conditions found: ' + str(len(segmentFilterCriteria)))
  print('Where clause criteria: ' + str(segmentFilterCriteria))
  </code></pre>
  
  <p>Console shows:</p>
  
  <pre><code>Number of where clause conditions found: 1
  Where clause criteria: ["source_data.loc[source_data['CONFIG_ID'] == 3]"]
  </code></pre>
  
  <p>Now, when I run this (i.e. using the text string and the exec function), my <code>base_data</code> dataframe appears as NoneType:</p>
  
  <pre><code>print(segmentFilterCriteria[0])
  base_data = exec(segmentFilterCriteria[0])
  print(base_data.columns)
  </code></pre>
  
  <p>Console shows:</p>
  
  <pre><code>source_data.loc[source_data['CONFIG_ID'] == 3]
  Traceback (most recent call last):
  
    File "&lt;ipython-input-95-17bc7d85852e&gt;", line 3, in &lt;module&gt;
      print(base_data.columns)
  
  AttributeError: 'NoneType' object has no attribute 'columns'
  </code></pre>
  
  <p>However, when I just type the code out, like this, it works fine:</p>
  
  <pre><code>base_data = source_data.loc[source_data['CONFIG_ID'] == 3]
  print(base_data.columns)
  </code></pre>
  
  <p>Console shows:</p>
  
  <pre><code>Index(['CONFIG_ID', 'ACCOUNT_DEAL_ID', 'FACILITY_ID',
         'M12_PD_INITIAL_RECOG_VAL',
  ...
  </code></pre>
  
  <p>Why does my string executed inside an <code>exec</code> function not work in this case?</p>