Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lectures/polars.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ As in {doc}`pandas`, Python makes it straightforward to query online databases.

An important database for economists is [FRED](https://fred.stlouisfed.org/) --- a vast collection of time series data maintained by the St. Louis Fed.

Polars' `read_csv` can fetch data from a URL directly.
We download the CSV file with [requests](https://requests.readthedocs.io/en/latest/)
and pass its contents to Polars' `read_csv`.

We use `try_parse_dates=True` to parse the date column automatically

Expand All @@ -564,7 +565,10 @@ fred_url = ('https://fred.stlouisfed.org/graph/fredgraph.csv?'
'fgst=lin&fgsnd=2020-02-01&line_index=1&'
'transformation=lin&vintage_date=2024-07-29&'
'revision_date=2024-07-29&nd=1948-01-01')
data = pl.read_csv(fred_url, try_parse_dates=True)
import requests
Comment thread
mmcky marked this conversation as resolved.

r = requests.get(fred_url)
data = pl.read_csv(r.content, try_parse_dates=True)
```

Let's inspect the first few rows
Expand Down
Loading