Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipe example in basics.rst broken due to SciPy / statsmodels changes #19713

Closed
TomAugspurger opened this issue Feb 15, 2018 · 2 comments · Fixed by #19923
Closed

pipe example in basics.rst broken due to SciPy / statsmodels changes #19713

TomAugspurger opened this issue Feb 15, 2018 · 2 comments · Fixed by #19923

Comments

@TomAugspurger
Copy link
Contributor

AttributeErrorTraceback (most recent call last)
<ipython-input-140-7e4e9a85c845> in <module>()
      1 (bb.query('h > 0')
      2    .assign(ln_h = lambda df: np.log(df.h))
----> 3    .pipe((sm.poisson, 'data'), 'hr ~ ln_h + year + g + C(lg)')
      4    .fit()
      5    .summary()
~/miniconda3/envs/pandas/lib/python3.6/site-packages/statsmodels/discrete/discrete_model.py in summary(self, yname, xname, title, alpha, yname_list)
   2548                      ('Log-Likelihood:', None),
   2549                      ('LL-Null:', ["%#8.5g" % self.llnull]),
-> 2550                      ('LLR p-value:', ["%#6.4g" % self.llr_pvalue])
   2551                      ]
   2552 
~/miniconda3/envs/pandas/lib/python3.6/site-packages/statsmodels/tools/decorators.py in __get__(self, obj, type)
     95         if _cachedval is None:
     96             # Call the "fget" function
---> 97             _cachedval = self.fget(obj)
     98             # Set the attribute in obj
     99             # print("Setting %s in cache to %s" % (name, _cachedval))
~/miniconda3/envs/pandas/lib/python3.6/site-packages/statsmodels/discrete/discrete_model.py in llr_pvalue(self)
   2403     @cache_readonly
   2404     def llr_pvalue(self):
-> 2405         return stats.chisqprob(self.llr, self.df_model)
   2406 
   2407     @cache_readonly
AttributeError: module 'scipy.stats' has no attribute 'chisqprob'
<<<-------------------------------------------------------------------------

Just do something other than poisson. Or remove statsmodels entirely, that's not the crucial point of the example.

@TomAugspurger TomAugspurger added this to the Next Major Release milestone Feb 15, 2018
@jbrockmendel
Copy link
Member

Yah AFAICT statsmodels has no intention of fixing this on their end. I've been patching scipy.stats at import-time to avoid this.

@ccatalfo
Copy link
Contributor

I submitted a pull request #19923 which changes the example piping to statsmodels from poisson to ols.

@jreback jreback modified the milestones: Next Major Release, 0.23.0 Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants