title: creating pandas dataframe with a function throwing 'df not defined' error
body: <p>I have created a function as below to create a dataframe from a bigger dataframe</p>
  
  <pre><code>def prepare_data(cyl,typ):
  global variable_name
  global variable_name2
  mask_bel1800 = (data_train_bel1800['Cycle'] == cyl) &amp; (data_train_bel1800['Type'] == typ)
  variable_name = ("DF{c}_{s}".format(c=cyl, s=typ))
  variable_name = data_train_bel1800.loc[mask_bel1800, :]
  
  
  mask = (data_train['Cycle'] == cyl) &amp; (data_train['Type'] == typ)
  variable_name2 = ("DF{c}_{s}_full".format(c=cyl, s=typ))
  variable_name2 = data_train.loc[mask, :]
  
  print('dataframe ' +'"DF'+str(cyl)+'_'+str(typ) +'"'+ " upto 1800 is ready")
  print('dataframe ' +'"DF'+str(cyl)+'_'+str(typ)+'_full'+'"' " is ready")
  </code></pre>
  
  <p>When I put the statement <code>print(variable_name)</code> inside this function, the dataframe is printed. 
  However, after i run this function &amp; then I try to access the dataframe with <code>df.head()</code>, i get the error 'df is not defined'!!! what i am doing wrong?</p>
  
  <p>Error i am getting is below
  <a href="https://i.stack.imgur.com/YcR3N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YcR3N.png" alt="enter image description here"></a></p>
  
  <p>If I 'print' the dataframe directly, it prints (pic below)
  <a href="https://i.stack.imgur.com/4ZFhX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4ZFhX.png" alt="enter image description here"></a></p>
  
  <p>I checked to make sure i have the right dataframe name by print just the variable "Variable name" and that is correct also<img src="https://i.stack.imgur.com/RbNX9.png" alt="![enter image description here">]<a href="https://i.stack.imgur.com/RbNX9.png" rel="nofollow noreferrer">3</a></p>