title: New columns not assigned in custom function (Python)
body: <p>My goal is to define a function that overwrites whatever input is given to it. It should add columns to the object and then merge it with a data frame defined within the function itself. I noticed that the columns I manually declare are being written on the object, but the columns that result from a merge are not being added.</p>
  <p>This is what my data, <code>df</code>, looks like:</p>
  <pre><code>  col1                  col2
  0    Q       V V V V V V V V
  1    Q             V V V V V
  2    Q       V V V V V V V V
  3    Q   V V-- V V V V V V V
  4    Q   V V V V V V V V V V
  </code></pre>
  <p>In this dummy example, I would like to write a custom function that adds a column full of ones to the input and then merges it with another data frame. Note that the function is not returning another object, but rather, it is overwriting the object that was fed to it.</p>
  <pre class="lang-py prettyprint-override"><code>def f(data):
      from pandas import DataFrame, merge  
      data['ones'] = 1
      temp = DataFrame({'col1':['C','Q','M'], 'col3':[14,15,30]})
      data = merge(data, temp, on='col1')
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>f(df)
    col1                  col2  ones
  0    Q       V V V V V V V V     1
  1    Q             V V V V V     1
  2    Q       V V V V V V V V     1
  3    Q   V V-- V V V V V V V     1
  4    Q   V V V V V V V V V V     1
  </code></pre>
  <p>Why is the result from the <code>merge</code> not being written over <code>df</code> while the <code>df['ones']</code> is?</p>