Comments (9)
Hi,
For what it's worth, I managed to run the code in python 3 by commenting the line that sets the encoding.
from thinkstats2.
It looks like Issue #15 is back. It's a problem with Patsy, so I don't have an easy way to fix it. Encoding the formula as ascii seemed like it solved the problem, but apparently not.
Since I can't fix it, I added an error message: ca7e911
Workarounds:
- Use Python 2 for this example.
- Skip this example.
Sorry!
from thinkstats2.
It seems the same problem happens with Python2 as well. I get the stack trace encountered by @LucianU. The relevant output of my Pandas environment from pd.show_versions(as_json=False)
is
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Darwin
OS-release: 13.4.0
machine: x86_64
pandas: 0.17.0
Cython: 0.22
numpy: 1.10.1
scipy: 0.15.1
statsmodels: 0.6.1
patsy: 0.3.0
I was able to get the sample to work if I encoded the formula as suggested in #15.
formula = ('totalwgt_lb ~ agepeg + ' + name).encode('ascii')
from thinkstats2.
I can confirm that I'm using Python 2.
from thinkstats2.
Right, it looks like we need to encode the formula for both Python 2 and 3.
But in 3 it looks like it doesn't work even with the encode.
So the code in regression.py is the best I can do for now.
The example in the book doesn't include the encode step. I can add it, but I am not sure whether it will decrease the net level of confusion. Thinking...
from thinkstats2.
And does the encoding suggested by Paul Glezen work for you, too?
On Wed, Nov 25, 2015 at 5:37 AM, Lucian Ursu [email protected]
wrote:
I can confirm that I'm using Python 2.
—
Reply to this email directly or view it on GitHub
#31 (comment)
.
from thinkstats2.
@AllenDowney, yes it does. I think it's worth adding it the book and specifying that it's needed because of an issue in patsy
.
from thinkstats2.
If I understand the issues:
-
In Python 2, the code in regression.py works because it encodes the
patsy formula as ascii. But the code in the book omits this line, so if
someone tries to run the code directly from the book, they're going to get
a confusing message. I am not sure whether adding this to the book will
increase or decrease the total amount of confusion. -
In Python 3, it seems, the code in regression.py doesn't work despite
the fact that it encodes the formula in ascii. It doesn't look like I can
fix this.
On Wed, Dec 2, 2015 at 2:57 AM, Lucian Ursu [email protected]
wrote:
@AllenDowney https://github.com/AllenDowney, yes it does.
—
Reply to this email directly or view it on GitHub
#31 (comment)
.
from thinkstats2.
Thanks @FlorianGD, the commenting worked for me too (in Python 3).
from thinkstats2.
Related Issues (20)
- using Pmf and Cdf HOT 2
- Typo in CONTRIBUTOR.md HOT 1
- potential typo in section 1.4
- Requirements.txt file for libraries
- figure 2.5, legend colors are wrong HOT 1
- Data Description for fem resp HOT 1
- Codebook server unavailable HOT 1
- Code in Chapter 6 Exercises for 'def InterpolateSample' thows an error HOT 2
- Intuition behind section 12.8 modeling and predictive uncertainty HOT 2
- Chapter 13 Solutions def ResampleDivorceCurve HOT 3
- FileNotFoundError: [Errno 2] No such file or directory: '2002FemResp.dct',, '2006_2010_FemPregSetup.dct' HOT 1
- the zip file is damaged HOT 4
- np.int is deprecated as of numpy 1.2 HOT 1
- Minor typo and clarification for exercise 3.4 HOT 3
- Update CDC NSFG Url in chap01ex.ipynb HOT 1
- Solution is Wrong chap01soln.ipynb HOT 1
- missing log-log scale in solution for Weibull transform (chap05soln.ipynb) HOT 1
- mismatch between documentation and code in thinkstats2.Jitter HOT 1
- two tasks in homework 4 seem to be identical HOT 1
- Missing Matplotlib HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thinkstats2.