title: Simple linear regression using pandas dataframe
body: <p>I'm looking to check trends for a number of entities (SysNr)</p>
  
  <p>I have data spanning 3 years (2014,2015,2016)</p>
  
  <p>I'm looking at a large quantity of variables, but will limit this question to one ('res_f_r')</p>
  
  <p>My DataFrame looks something like this</p>
  
  <pre><code>d = [
      {'RegnskabsAar': 2014, 'SysNr': 1, 'res_f_r': 350000},
      {'RegnskabsAar': 2015, 'SysNr': 1, 'res_f_r': 400000},
      {'RegnskabsAar': 2016, 'SysNr': 1, 'res_f_r': 450000},
      {'RegnskabsAar': 2014, 'SysNr': 2, 'res_f_r': 350000},
      {'RegnskabsAar': 2015, 'SysNr': 2, 'res_f_r': 300000},
      {'RegnskabsAar': 2016, 'SysNr': 2, 'res_f_r': 250000},
  ]
  
  df = pd.DataFrame(d)
  
  
  
     RegnskabsAar  SysNr  res_f_r
  0          2014      1   350000
  1          2015      1   400000
  2          2016      1   450000
  3          2014      2   350000
  4          2015      2   300000
  5          2016      2   250000
  </code></pre>
  
  <p>My desire is to do a linear regression on each entity (SysNr) and get returned the slope and intercept</p>
  
  <p>My desired output for the above is </p>
  
  <pre><code>   SysNr  intercept  slope
  0      1     300000  50000
  1      2     400000 -50000
  </code></pre>
  
  <p>Any ideas?</p>