Skip to content

Commit

Permalink
content/pandas: Adjust lesson to use local copy of laureates.csv
Browse files Browse the repository at this point in the history
- csv already added in previous commit (so that this can be tested)
  • Loading branch information
rkdarst committed Nov 7, 2023
1 parent e1bd3d8 commit 6dc453d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions content/pandas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,15 @@ an API of the Nobel prize organisation at
https://api.nobelprize.org/v1/laureate.csv .

Unfortunately this API does not allow "non-browser requests", so
:obj:`pandas.read_csv` will not work. We can either open the above link in
a browser and download the file, or use the JupyterLab interface by clicking
"File" and "Open from URL", and then save the CSV file to disk.
:obj:`pandas.read_csv` will not work directly on it. Instead, we put a
local copy on Github which we can access (the original data is CC-0,
so we are allowed to do this). (Aside: if you do JupyterLab →
File → Open from URL → paste the URL above, it will open it in
JupyterLab *and* download a copy for your use.)

We can then load and explore the data::

# File → Open from URL → enter https://api.nobelprize.org/v1/laureate.csv
# This opens it in JupyterLab but also saves it as laureate.csv
nobel = pd.read_csv("laureate.csv")
nobel = pd.read_csv("https://github.com/AaltoSciComp/python-for-scicomp/raw/master/resources/data/laureate.csv")
nobel.head()

This dataset has three columns for time, "born"/"died" and "year".
Expand Down

0 comments on commit 6dc453d

Please sign in to comment.