Repository: statsmodels/statsmodels

Issue:
SettingWithCopyError in statsmodels.iolib.summary2._col_params
If you use `pandas.set_option('chained_assignment',"raise")`, I get the following error when using `summary_col`:

```
---------------------------------------------------------------------------
SettingWithCopyError                      Traceback (most recent call last)
<ipython-input-50-3c8e3f7f5e1b> in <module>()
      1 summ = get_regressions_as_table(df_business, 
      2                              dependent, network_sc_combis[0], special_sc, performance_before, control,
----> 3                              norm_network=True, ztransform=False)
      4 print(summ)

<ipython-input-49-a26aff3d6a09> in get_regressions_as_table(data, dependent, network_sc, special_sc, performance_before, control, norm_network, ztransform)
     40         model_names.append(res.model.endog_names)
     41     names = [s.replace("np.log(", "log(").replace(" + 1)", ")").replace("standardize(","").replace(")","") for s in model_names]
---> 42     summary = summary_col(output, float_format="%.4f", model_names=names, info_dict=custom_info, stars=True)
     43     return summary

C:\portabel\miniconda\envs\sc\lib\site-packages\statsmodels\iolib\summary2.pyc in summary_col(results, float_format, model_names, stars, info_dict, regressor_order)
    450 
    451     cols = [_col_params(x, stars=stars, float_format=float_format) for x in
--> 452             results]
    453 
    454     # Unique column names (pandas has problems merging otherwise)

C:\portabel\miniconda\envs\sc\lib\site-packages\statsmodels\iolib\summary2.pyc in _col_params(result, float_format, stars)
    370     if stars:
    371         idx = res.ix[:, 3] < .1
--> 372         res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'
    373         idx = res.ix[:, 3] < .05
    374         res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'

C:\portabel\miniconda\envs\sc\lib\site-packages\pandas\core\series.pyc in __setitem__(self, key, value)
    685 
    686         # do the setitem
--> 687         cacher_needs_updating = self._check_is_chained_assignment_possible()
    688         setitem(key, value)
    689         if cacher_needs_updating:

C:\portabel\miniconda\envs\sc\lib\site-packages\pandas\core\generic.pyc in _check_is_chained_assignment_possible(self)
   1219             ref = self._get_cacher()
   1220             if ref is not None and ref._is_mixed_type:
-> 1221                 self._check_setitem_copy(stacklevel=4, t='referant', force=True)
   1222             return True
   1223         elif self.is_copy:

C:\portabel\miniconda\envs\sc\lib\site-packages\pandas\core\generic.pyc in _check_setitem_copy(self, stacklevel, t, force)
   1300 
   1301             if value == 'raise':
-> 1302                 raise SettingWithCopyError(t)
   1303             elif value == 'warn':
   1304                 warnings.warn(t, SettingWithCopyWarning, stacklevel=stacklevel)

SettingWithCopyError: 
A value is trying to be set on a copy of a slice from a DataFrame

See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

```



Discussion:
IMO, the offending lines could be replaced by:

``` patch
- res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'
+ res.ix[idx, 0] = res.ix[idx, 0] + '*'
```


Resolving patch:
diff --git a/statsmodels/iolib/summary2.py b/statsmodels/iolib/summary2.py
--- a/statsmodels/iolib/summary2.py
+++ b/statsmodels/iolib/summary2.py
@@ -369,11 +369,11 @@ def _col_params(result, float_format='%.4f', stars=True):
     # Significance stars
     if stars:
         idx = res.ix[:, 3] < .1
-        res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'
+        res.ix[idx, 0] = res.ix[idx, 0] + '*'
         idx = res.ix[:, 3] < .05
-        res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'
+        res.ix[idx, 0] = res.ix[idx, 0] + '*'
         idx = res.ix[:, 3] < .01
-        res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'
+        res.ix[idx, 0] = res.ix[idx, 0] + '*'
     # Stack Coefs and Std.Errors
     res = res.ix[:, :2]
     res = res.stack()


Test patch: