Skip to content

Commit 2e1af13

Browse files
committed
project start
1 parent ec7bb37 commit 2e1af13

6 files changed

+2015
-18
lines changed

.direnv/bin/nix-direnv-reload

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
if [[ ! -d "/home/b-rodrigues/Documents/github_repos/raps_with_py" ]]; then
4+
echo "Cannot find source directory; Did you move it?"
5+
echo "(Looking for "/home/b-rodrigues/Documents/github_repos/raps_with_py")"
6+
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
7+
exit 1
8+
fi
9+
10+
# rebuild the cache forcefully
11+
_nix_direnv_force_reload=1 direnv exec "/home/b-rodrigues/Documents/github_repos/raps_with_py" true
12+
13+
# Update the mtime for .envrc.
14+
# This will cause direnv to reload again - but without re-building.
15+
touch "/home/b-rodrigues/Documents/github_repos/raps_with_py/.envrc"
16+
17+
# Also update the timestamp of whatever profile_rc we have.
18+
# This makes sure that we know we are up to date.
19+
touch -r "/home/b-rodrigues/Documents/github_repos/raps_with_py/.envrc" "/home/b-rodrigues/Documents/github_repos/raps_with_py/.direnv"/*.rc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/nix/store/6601lrikzr0dibahxc7zgl5mraiyrpjg-nix-shell-env

.direnv/nix-profile-24.11-r7v61ryzzq60fkzq.rc

+1,981
Large diffs are not rendered by default.

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use nix

project_start.qmd

+12-17
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ analytical pipeline. To get things going, we are going to keep it simple; our
88
goal here is to get an analysis done, that's it. We won't focus on
99
reproducibility (well, not beyond what was done in the previous chapter to set
1010
up our development environment). We are going to download some data, and analyse
11-
it, that's it. But before all of that, I will present the Polars package. In the
12-
preface, I said that this wasn’t supposed to be a book about Python, so why am
13-
I talking about a specific package? It’s because I think that Polars, unlike Pandas,
14-
has some features and design choices that actually improve reproducibility.
15-
16-
## The Polars package and why you should ditch Pandas in its favour
17-
18-
11+
it, that's it.
1912

2013
## Housing in Luxembourg
2114

@@ -50,11 +43,11 @@ knitr::include_graphics("images/lux_rhode_island.png")
5043
```
5144
:::
5245

53-
What you should also know is that the population is about 645,000 as of writing
54-
(January 2023), half of which are foreigners. Around 400,000 persons work in
55-
Luxembourg, of which half do not live in Luxembourg; so every morning from
56-
Monday to Friday, 200,000 people enter the country to work and then leave in the
57-
evening to go back to either Belgium, France or Germany, the neighbouring
46+
What you should also know is that the population is about 672,050 people as of
47+
writing (July 2024), half of which are foreigners. Around 400,000 persons
48+
work in Luxembourg, of which half do not live in Luxembourg; so every morning
49+
from Monday to Friday, 200,000 people enter the country to work and then leave
50+
in the evening to go back to either Belgium, France or Germany, the neighbouring
5851
countries. As you can imagine, this puts enormous pressure on the transportation
5952
system and on the roads, but also on the housing market; everyone wants to live
6053
in Luxembourg to avoid the horrible daily commute, and everyone wants to live
@@ -88,10 +81,11 @@ If you want to download the data, click
8881
Let us paste the definition of the HPI in here (taken from the HPI's
8982
[metadata](https://archive.is/OrQwA)^[https://archive.is/OrQwA, archived link for posterity.] page):
9083

91-
*The House Price Index (HPI) measures inflation in the residential property market. The HPI
92-
captures price changes of all types of dwellings purchased by households (flats, detached houses,
93-
terraced houses, etc.). Only transacted dwellings are considered, self-build dwellings are
94-
excluded. The land component of the dwelling is included.*
84+
*The House Price Index (HPI) measures inflation in the residential property
85+
market. The HPI captures price changes of all types of dwellings purchased by
86+
households (flats, detached houses, terraced houses, etc.). Only transacted
87+
dwellings are considered, self-build dwellings are excluded. The land component
88+
of the dwelling is included.*
9589

9690
So from the plot, we can see that the price of dwellings more than doubled
9791
between 2010 and 2021; the value of the index is 214.81 in 2021 for Luxembourg,
@@ -202,6 +196,7 @@ import polars as pl
202196
import polars.selectors as cs
203197
import re
204198
```
199+
205200
I will be using the `polars` package to manipulate data.
206201

207202
Next, the code below downloads the data, and puts it in a data frame:

scripts/save_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read_excel(excel_file, sheet):
1111
out = pl.read_excel(
1212
source = excel_file,
1313
sheet_name = sheet,
14-
read_csv_options = {
14+
read_options = {
1515
"skip_rows": 6,
1616
"has_header": True
1717
}

0 commit comments

Comments
 (0)