Runner Bean - 1 year ago 100

Python Question

Using a Pandas dataframe and the stats ols method, Im able to run a regression using the code

`import pandas as pd`

from pandas.stats.api import ols

df = pd.DataFrame({"A": [56, 55, 57, 58, 56, 58, 59, 60, 63, 62, 63, 65, 66, 68], "B": [1,2,3,4,5,6,7,8,9,10,11,12,13,14]})

res = ols(y=df['A'], x=df[['B']])

However although this works

`print res`

Im trying to get just the fitted coefficient, and this does not work

`print res.params`

i get the error

`AttributeError: 'OLS' object has no attribute 'params'`

how can I access the parameters, I am particularly looking the extract the coefficient of the regression, that is all I am interested in.

Answer Source

try

```
res.beta
B 0.945055
intercept 53.340659
dtype: float64
In [48]:
```

For just `B`

```
res.beta.B
0.945055
```