title: Exponential fit in pandas
body: <p>I have this data:</p>
  <pre class="lang-py prettyprint-override"><code>puf = pd.DataFrame({'id':[1,2,3,4,5,6,7,8],
                      'val':[850,1889,3289,6083,10349,17860,28180,41236]})
  </code></pre>
  <p>The data seems to follow an exponential curve. Let's see the plot:</p>
  <pre class="lang-py prettyprint-override"><code>puf.plot('id','val')
  </code></pre>
  <p><a href="https://i.stack.imgur.com/i22bq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i22bq.png" alt="enter image description here" /></a></p>
  <p>I want to fit an exponential curve (<code>$$ y = Ae^{Bx} $$</code>, A times e to the B*X)and add it as a column in Pandas. Firstly I tried to log the values:</p>
  <pre class="lang-py prettyprint-override"><code>puf['log_val'] = np.log(puf['val'])
  </code></pre>
  <p>And then to use Numpy to fit the equation:</p>
  <pre class="lang-py prettyprint-override"><code>puf['fit'] = np.polyfit(puf['id'],puf['log_val'],1)
  </code></pre>
  <p>But I get an error:</p>
  <pre><code>ValueError: Length of values (2) does not match length of index (8)
  </code></pre>
  <p>My expected result is the fitted values as a new column in Pandas. I attach an image with the column fitted values I want (in orange):</p>
  <p><a href="https://i.stack.imgur.com/4wqFr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4wqFr.png" alt="enter image description here" /></a></p>
  <p>I'm stuck in this code. I'm not sure what I am doing wrong. How can I create a new column with my fitted values?</p>