{"action":"created","issue":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2519","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2519/labels{/name}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2519/comments","events_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2519/events","html_url":"https://github.com/statsmodels/statsmodels/issues/2519","id":94405677,"number":2519,"title":"SettingWithCopyError in statsmodels.iolib.summary2._col_params","user":{"login":"JanSchulz","id":890156,"avatar_url":"https://avatars.githubusercontent.com/u/890156?v=3","gravatar_id":"","url":"https://api.github.com/users/JanSchulz","html_url":"https://github.com/JanSchulz","followers_url":"https://api.github.com/users/JanSchulz/followers","following_url":"https://api.github.com/users/JanSchulz/following{/other_user}","gists_url":"https://api.github.com/users/JanSchulz/gists{/gist_id}","starred_url":"https://api.github.com/users/JanSchulz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanSchulz/subscriptions","organizations_url":"https://api.github.com/users/JanSchulz/orgs","repos_url":"https://api.github.com/users/JanSchulz/repos","events_url":"https://api.github.com/users/JanSchulz/events{/privacy}","received_events_url":"https://api.github.com/users/JanSchulz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-10T22:30:27Z","updated_at":"2015-07-10T22:44:55Z","closed_at":null,"body":"If you use `pandas.set_option('chained_assignment',\"raise\")`, I get the following error when using `summary_col`:\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nSettingWithCopyError                      Traceback (most recent call last)\r\n<ipython-input-50-3c8e3f7f5e1b> in <module>()\r\n      1 summ = get_regressions_as_table(df_business, \r\n      2                              dependent, network_sc_combis[0], special_sc, performance_before, control,\r\n----> 3                              norm_network=True, ztransform=False)\r\n      4 print(summ)\r\n\r\n<ipython-input-49-a26aff3d6a09> in get_regressions_as_table(data, dependent, network_sc, special_sc, performance_before, control, norm_network, ztransform)\r\n     40         model_names.append(res.model.endog_names)\r\n     41     names = [s.replace(\"np.log(\", \"log(\").replace(\" + 1)\", \")\").replace(\"standardize(\",\"\").replace(\")\",\"\") for s in model_names]\r\n---> 42     summary = summary_col(output, float_format=\"%.4f\", model_names=names, info_dict=custom_info, stars=True)\r\n     43     return summary\r\n\r\nC:\\portabel\\miniconda\\envs\\sc\\lib\\site-packages\\statsmodels\\iolib\\summary2.pyc in summary_col(results, float_format, model_names, stars, info_dict, regressor_order)\r\n    450 \r\n    451     cols = [_col_params(x, stars=stars, float_format=float_format) for x in\r\n--> 452             results]\r\n    453 \r\n    454     # Unique column names (pandas has problems merging otherwise)\r\n\r\nC:\\portabel\\miniconda\\envs\\sc\\lib\\site-packages\\statsmodels\\iolib\\summary2.pyc in _col_params(result, float_format, stars)\r\n    370     if stars:\r\n    371         idx = res.ix[:, 3] < .1\r\n--> 372         res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'\r\n    373         idx = res.ix[:, 3] < .05\r\n    374         res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'\r\n\r\nC:\\portabel\\miniconda\\envs\\sc\\lib\\site-packages\\pandas\\core\\series.pyc in __setitem__(self, key, value)\r\n    685 \r\n    686         # do the setitem\r\n--> 687         cacher_needs_updating = self._check_is_chained_assignment_possible()\r\n    688         setitem(key, value)\r\n    689         if cacher_needs_updating:\r\n\r\nC:\\portabel\\miniconda\\envs\\sc\\lib\\site-packages\\pandas\\core\\generic.pyc in _check_is_chained_assignment_possible(self)\r\n   1219             ref = self._get_cacher()\r\n   1220             if ref is not None and ref._is_mixed_type:\r\n-> 1221                 self._check_setitem_copy(stacklevel=4, t='referant', force=True)\r\n   1222             return True\r\n   1223         elif self.is_copy:\r\n\r\nC:\\portabel\\miniconda\\envs\\sc\\lib\\site-packages\\pandas\\core\\generic.pyc in _check_setitem_copy(self, stacklevel, t, force)\r\n   1300 \r\n   1301             if value == 'raise':\r\n-> 1302                 raise SettingWithCopyError(t)\r\n   1303             elif value == 'warn':\r\n   1304                 warnings.warn(t, SettingWithCopyWarning, stacklevel=stacklevel)\r\n\r\nSettingWithCopyError: \r\nA value is trying to be set on a copy of a slice from a DataFrame\r\n\r\nSee the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/comments/120545119","html_url":"https://github.com/statsmodels/statsmodels/issues/2519#issuecomment-120545119","issue_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/2519","id":120545119,"user":{"login":"JanSchulz","id":890156,"avatar_url":"https://avatars.githubusercontent.com/u/890156?v=3","gravatar_id":"","url":"https://api.github.com/users/JanSchulz","html_url":"https://github.com/JanSchulz","followers_url":"https://api.github.com/users/JanSchulz/followers","following_url":"https://api.github.com/users/JanSchulz/following{/other_user}","gists_url":"https://api.github.com/users/JanSchulz/gists{/gist_id}","starred_url":"https://api.github.com/users/JanSchulz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanSchulz/subscriptions","organizations_url":"https://api.github.com/users/JanSchulz/orgs","repos_url":"https://api.github.com/users/JanSchulz/repos","events_url":"https://api.github.com/users/JanSchulz/events{/privacy}","received_events_url":"https://api.github.com/users/JanSchulz/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T22:44:55Z","updated_at":"2015-07-10T22:44:55Z","body":"IMO, the offending lines could be replaced by:\r\n\r\n```patch\r\n- res.ix[:, 0][idx] = res.ix[:, 0][idx] + '*'\r\n+res.ix[idx, 0] = res.ix[idx, 0] + '*'\r\n```"}}