AllenDowney / ThinkBayes2

Text and code for the forthcoming second edition of Think Bayes, by Allen Downey.
http://allendowney.github.io/ThinkBayes2/
MIT License
1.8k stars 1.49k forks source link

Chapter 1 download data code isn't working #57

Closed HelloWorld183L closed 2 years ago

HelloWorld183L commented 2 years ago

I found that the original code seems to be outdated since it seems to use a different repository name (BiteSizeBayes) and it uses a csv file whereas the current data is in a gss_bayes folder which I don't know how to read/use (normally I use csv files). Can anyone give guidance on how to read in this data (e.g. docs) or a pointer on where to find the original GSS data? Thanks in advance.

Here's the original code for context:

`# Load the data file

from os.path import basename, exists

def download(url): filename = basename(url) if not exists(filename): from urllib.request import urlretrieve local, _ = urlretrieve(url, filename) print('Downloaded ' + local)

download('https://github.com/AllenDowney/BiteSizeBayes/raw/master/gss_bayes.csv')`

AllenDowney commented 2 years ago

Which file is this in?

HelloWorld183L commented 2 years ago

Which file is this in?

This is in chap01.ipynb (https://github.com/AllenDowney/ThinkBayes2/blob/master/notebooks/chap01.ipynb)

AllenDowney commented 2 years ago

This notebook runs on Colab without problems:

https://colab.research.google.com/github/AllenDowney/ThinkBayes2/blob/master/notebooks/chap01.ipynb

I recommend running the notebooks on Colab.

I think I don't understand what you are asking.

HelloWorld183L commented 2 years ago

What I was trying to say was that the notebook I linked doesn't retrieve the gss_bayes.csv file properly (404) whereas the Collab notebook works fine. I don't see the gss_bayes.csv file in this GitHub repository and the Collab notebook ends up using the csv file from a different repository which I initially found confusing since there's a "gss_bayes" folder that I assumed would have the data I need. In other words, I assumed the original data was meant to be in this repository because of the different data folders and the "gss_bayes" folder. I'll stick to the Collab notebooks for now since they seem to work just fine.

For extra context, here is the error I was getting when running the non-Collab notebook:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)>

AllenDowney commented 2 years ago

It's intentional that it's coming from a different repo. But maybe that's causing something in your development environment to object. Anyway, if Colab works, you are all set!