mobisurvstd 1.4.1__tar.gz → 1.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mobisurvstd-1.4.1/src/mobisurvstd.egg-info → mobisurvstd-1.4.2}/PKG-INFO +1 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/pyproject.toml +13 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/__init__.py +0 -3
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/common.py +1 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/deplacements.py +18 -17
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/edvm.py +2 -2
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/emd.py +2 -2
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/menages.py +7 -6
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/personnes.py +27 -26
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/reader.py +4 -4
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/survey.py +34 -29
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/trajets.py +18 -17
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/zones.py +1 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/classes.py +7 -10
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cli.py +10 -4
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/cars.py +1 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/clean.py +4 -2
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/households.py +1 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/legs.py +1 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/motorcycles.py +1 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/persons.py +3 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/trips.py +3 -3
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2010/deplacements.py +13 -12
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2010/personnes.py +8 -7
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2010/trajets.py +8 -7
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/deplacements.py +10 -9
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/menages.py +5 -5
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/personnes.py +7 -6
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/trajets.py +13 -12
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/voitures.py +1 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emg2023/deplacements.py +4 -3
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emg2023/personnes.py +3 -2
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/deplacements.py +17 -16
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/menages.py +2 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/personnes.py +6 -5
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/voitures.py +1 -0
- mobisurvstd-1.4.2/src/mobisurvstd/logger.py +26 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/main.py +3 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/resources/__init__.py +4 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/resources/admin_express.py +3 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/resources/nuts.py +1 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/common.py +3 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/guarantees.py +13 -4
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/trips.py +4 -1
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/utils.py +4 -4
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/validation.py +6 -6
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2/src/mobisurvstd.egg-info}/PKG-INFO +1 -1
- mobisurvstd-1.4.1/src/mobisurvstd/logger.py +0 -15
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/LICENSE.md +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/README.md +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/setup.cfg +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/__main__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/__init__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/edgt.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/emc2.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/cerema/nantes_opendata.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/__init__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/common/zones.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2010/__init__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2010/menages.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2010/survey.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2010/zones.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/__init__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/motos.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/egt2020/survey.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emg2023/__init__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emg2023/menages.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emg2023/survey.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/__init__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/common.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/motos.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/emp/survey.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/resources/insee_data.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/__init__.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/cars.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/households.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/legs.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/motorcycles.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd/schema/persons.py +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd.egg-info/SOURCES.txt +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd.egg-info/dependency_links.txt +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd.egg-info/entry_points.txt +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd.egg-info/requires.txt +0 -0
- {mobisurvstd-1.4.1 → mobisurvstd-1.4.2}/src/mobisurvstd.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mobisurvstd
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.2
|
|
4
4
|
Summary: A tool to standardize French mobility survey datasets (EMC2, EGT, EMP, etc.) into a unified format.
|
|
5
5
|
Author-email: Lucas Javaudin <lucas@lucasjavaudin.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "mobisurvstd"
|
|
9
|
-
version = "1.4.
|
|
9
|
+
version = "1.4.2"
|
|
10
10
|
description = "A tool to standardize French mobility survey datasets (EMC2, EGT, EMP, etc.) into a unified format."
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
authors = [{ name = "Lucas Javaudin", email = "lucas@lucasjavaudin.com" }]
|
|
@@ -52,11 +52,23 @@ dev = [
|
|
|
52
52
|
"ipython>=8.37.0",
|
|
53
53
|
"matplotlib>=3.10.1",
|
|
54
54
|
"pytest>=9.0.2",
|
|
55
|
+
"ruff>=0.16.4",
|
|
55
56
|
"seaborn>=0.13.2",
|
|
56
57
|
"ty>=0.0.15",
|
|
57
58
|
]
|
|
58
59
|
|
|
59
60
|
[tool.ruff]
|
|
60
61
|
line-length = 100
|
|
62
|
+
|
|
61
63
|
[tool.ruff.format]
|
|
62
64
|
skip-magic-trailing-comma = true
|
|
65
|
+
|
|
66
|
+
[tool.ruff.lint]
|
|
67
|
+
select = ["E", "F", "I", "UP", "RUF", "PLW"]
|
|
68
|
+
ignore = [
|
|
69
|
+
"C408", # C408: allow list() and dict() calls
|
|
70
|
+
]
|
|
71
|
+
preview = false
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint.isort]
|
|
74
|
+
split-on-trailing-comma = false
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# ruff: noqa: E501
|
|
1
2
|
import io
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
|
|
@@ -17,23 +18,23 @@ SCHEMA: dict[str, DataTypeClass] = {
|
|
|
17
18
|
"IDD3": pl.UInt16, # Année de fin d'enquête
|
|
18
19
|
"IDD4": pl.String, # Code Insee ville centre
|
|
19
20
|
"ZFD": pl.String, # Zone fine de résidence
|
|
20
|
-
"ECH": pl.UInt32, # Numéro d
|
|
21
|
+
"ECH": pl.UInt32, # Numéro d'échantillon
|
|
21
22
|
"PER": pl.UInt8, # Numéro de personne
|
|
22
23
|
"NDEP": pl.UInt8, # Numéro de déplacement
|
|
23
24
|
"GD1": pl.String, # Insee Zone fine du lieu de résidence de la personne concernée par le déplacement
|
|
24
|
-
"STD": pl.String, # Secteur de tirage dans l
|
|
25
|
+
"STD": pl.String, # Secteur de tirage dans l'enquête d'origine (résidence)
|
|
25
26
|
"D2A": pl.UInt8, # Motif Origine du déplacement
|
|
26
27
|
"D2B": pl.UInt8, # Motif Origine de la personne accompagnée
|
|
27
28
|
"D3": pl.String, # Zone fine Origine du déplacement
|
|
28
29
|
"GDO1": pl.String, # Insee Zone fine Origine du déplacement
|
|
29
|
-
"STDO": pl.String, # Secteur de tirage dans l
|
|
30
|
+
"STDO": pl.String, # Secteur de tirage dans l'enquête d'origine (origine du déplacement)
|
|
30
31
|
"D4": pl.Int32, # Heure de départ du déplacement
|
|
31
32
|
"D5A": pl.UInt8, # Motif Destination du déplacement
|
|
32
33
|
"D5B": pl.UInt8, # Motif Destination de la personne accompagnée
|
|
33
|
-
"D6": pl.UInt8, # Nombre d
|
|
34
|
+
"D6": pl.UInt8, # Nombre d'arrêts sur la tournée
|
|
34
35
|
"D7": pl.String, # Zone fine Destination du déplacement
|
|
35
36
|
"GDD1": pl.String, # Insee Zone fine Destination du déplacement
|
|
36
|
-
"STDD": pl.String, # Secteur de tirage dans l
|
|
37
|
+
"STDD": pl.String, # Secteur de tirage dans l'enquête d'origine (destination du déplacement)
|
|
37
38
|
"D8": pl.Int32, # Heure d'arrivée du déplacement
|
|
38
39
|
"D9": pl.Int32, # Durée du déplacement
|
|
39
40
|
"D10": pl.UInt8, # Nombre de trajets (en modes mécanisés)
|
|
@@ -46,8 +47,8 @@ SCHEMA: dict[str, DataTypeClass] = {
|
|
|
46
47
|
PURPOSE_MAP = {
|
|
47
48
|
1: "home:main", # Domicile (partir de, se rendre à).
|
|
48
49
|
2: "home:secondary", # Résidence secondaire, logement occasionnel, hôtel, autre domicile (partir de, se rendre à).
|
|
49
|
-
11: "work:usual", # Travailler sur le lieu d
|
|
50
|
-
12: "work:telework", # Travailler sur un autre lieu
|
|
50
|
+
11: "work:usual", # Travailler sur le lieu d'emploi déclaré.
|
|
51
|
+
12: "work:telework", # Travailler sur un autre lieu - télétravail.
|
|
51
52
|
13: "work:secondary", # Travailler sur un autre lieu hors télétravail
|
|
52
53
|
14: "work:other", # Travailler sur un autre lieu sans distinction
|
|
53
54
|
# NOTE. We discard the information on the exact study location type (middle-school, high-school,
|
|
@@ -61,7 +62,7 @@ PURPOSE_MAP = {
|
|
|
61
62
|
27: "education:other", # Étudier sur un autre lieu (collège).
|
|
62
63
|
28: "education:other", # Étudier sur un autre lieu (lycée).
|
|
63
64
|
29: "education:other", # Étudier sur un autre lieu (universités et grandes écoles).
|
|
64
|
-
30: "shopping:no_purchase", # Visite d
|
|
65
|
+
30: "shopping:no_purchase", # Visite d'un magasin, d'un centre commercial ou d'un marché de plein vent sans effectuer d'achat
|
|
65
66
|
31: "shopping:unspecified", # Réaliser plusieurs motifs en centre commercial.
|
|
66
67
|
32: "shopping:unspecified", # Faire des achats en grand magasin, supermarché, hypermarché et leurs galeries marchandes.
|
|
67
68
|
33: "shopping:unspecified", # Faire des achats en petit et moyen commerce et drive in
|
|
@@ -73,22 +74,22 @@ PURPOSE_MAP = {
|
|
|
73
74
|
44: "shopping:pickup", # OPEN DATA NANTES ONLY: RECUPERER UN ACHAT FAIT A DISTANCE (TEL, VPC, INTERNET…)
|
|
74
75
|
45: "task:procedure", # OPEN DATA NANTES ONLY: FAIRE UNE DEMARCHE AUTRE QUE RECHERCHER UN EMPLOI OU RECUPERER UN ACHAT FAIT A DISTANCE
|
|
75
76
|
51: "leisure:sport_or_culture", # Participer à des loisirs, des activités sportives, culturelles ou associatives.
|
|
76
|
-
52: "leisure:walk_or_driving_lesson", # Faire une promenade, du «
|
|
77
|
+
52: "leisure:walk_or_driving_lesson", # Faire une promenade, du « lèche-vitrines », prendre une leçon de conduite.
|
|
77
78
|
53: "leisure:restaurant", # Se restaurer hors du domicile.
|
|
78
79
|
54: "leisure:visiting", # Visiter des parents ou des amis.
|
|
79
80
|
# NOTE. We discard the information on whether the escorted person is present during pick_up /
|
|
80
81
|
# drop_off activity as it can be deduced (when I go pick-up someone, he's not there; when I come
|
|
81
82
|
# back from picking-up someone, he's there). Also, there are some errors in the data (like
|
|
82
83
|
# having the escorted person both before and after picking him up).
|
|
83
|
-
61: "escort:activity:drop_off", # Accompagner quelqu
|
|
84
|
-
62: "escort:activity:pick_up", # Aller chercher quelqu
|
|
85
|
-
63: "escort:activity:drop_off", # Accompagner quelqu
|
|
86
|
-
64: "escort:activity:pick_up", # Aller chercher quelqu
|
|
87
|
-
68: "escort:unspecified:drop_off", # Accompagner quelqu
|
|
88
|
-
69: "escort:unspecified:pick_up", # Aller chercher quelqu
|
|
84
|
+
61: "escort:activity:drop_off", # Accompagner quelqu'un (personne présente).
|
|
85
|
+
62: "escort:activity:pick_up", # Aller chercher quelqu'un (personne présente).
|
|
86
|
+
63: "escort:activity:drop_off", # Accompagner quelqu'un (personne absente).
|
|
87
|
+
64: "escort:activity:pick_up", # Aller chercher quelqu'un (personne absente).
|
|
88
|
+
68: "escort:unspecified:drop_off", # Accompagner quelqu'un ou déposer quelqu'un à un mode de transport (sans info présence personne)
|
|
89
|
+
69: "escort:unspecified:pick_up", # Aller chercher quelqu'un ou reprendre quelqu'un à un mode de transport (sans info présence personne)
|
|
89
90
|
71: "escort:transport:drop_off", # Déposer une personne à un mode de transport (personne présente).
|
|
90
91
|
72: "escort:transport:pick_up", # Reprendre une personne à un mode de transport (personne présente).
|
|
91
|
-
73: "escort:transport:drop_off", # Déposer d
|
|
92
|
+
73: "escort:transport:drop_off", # Déposer d'une personne à un mode de transport (personne absente).
|
|
92
93
|
74: "escort:transport:pick_up", # Reprendre une personne à un mode de transport( personne absente).
|
|
93
94
|
81: "work:professional_tour", # Réaliser une tournée professionnelle.
|
|
94
95
|
82: "shopping:tour_no_purchase", # Tournée de magasin sans achat
|
|
@@ -178,7 +179,7 @@ class TripsReader(CeremaReader):
|
|
|
178
179
|
arrival_time=pl.when(pl.col("D9") == pl.col("departure_time") - pl.col("arrival_time"))
|
|
179
180
|
.then("departure_time")
|
|
180
181
|
.otherwise("arrival_time"),
|
|
181
|
-
# When destination purpose is 52 (« Faire une promenade, du «
|
|
182
|
+
# When destination purpose is 52 (« Faire une promenade, du « lèche-vitrines », prendre
|
|
182
183
|
# une leçon de conduite. ») and `nb_tour_stops` is defined, then we know that purpose is
|
|
183
184
|
# « lèche-vitrines » so we can set purpose to "shopping:tour_no_purchase".
|
|
184
185
|
destination_purpose=pl.when(pl.col("D5A").eq(52), pl.col("nb_tour_stops").is_not_null())
|
|
@@ -190,8 +190,8 @@ class EDVMReader(CeremaStandardizer):
|
|
|
190
190
|
)
|
|
191
191
|
for sec_col, gt_num_col in pairs:
|
|
192
192
|
if sec_col in gdf.columns and gt_num_col in gdf.columns:
|
|
193
|
-
# The `gt_num_col` is cast to int then str to handle the Angoulème 2012 survey where
|
|
194
|
-
# column is of dtype float.
|
|
193
|
+
# The `gt_num_col` is cast to int then str to handle the Angoulème 2012 survey where
|
|
194
|
+
# the column is of dtype float.
|
|
195
195
|
gdf["special_location_id"] = gdf[sec_col] + gdf[gt_num_col].astype(int).astype(str)
|
|
196
196
|
break
|
|
197
197
|
# Normal case. Find the GT id column by name.
|
|
@@ -119,8 +119,8 @@ class EMDReader(CeremaStandardizer):
|
|
|
119
119
|
|
|
120
120
|
def preprocess_detailed_zones(self, gdf: gpd.GeoDataFrame):
|
|
121
121
|
if "Famille" in gdf.columns and "ZFIN2016F" in gdf.columns:
|
|
122
|
-
# Special case for Lille 2015: 110 ZFs are also GTs (they have the same id, the GT
|
|
123
|
-
# are within the ZF Polygons).
|
|
122
|
+
# Special case for Lille 2015: 110 ZFs are also GTs (they have the same id, the GT
|
|
123
|
+
# Points are within the ZF Polygons).
|
|
124
124
|
# We don't want to drop these "duplicate" ZFs (because other GTs are within these ZFs).
|
|
125
125
|
# So we create fake ID for them (by adding 50 to their ID).
|
|
126
126
|
mask = gdf["Famille"] != ""
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# ruff: noqa: E501
|
|
1
2
|
import io
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
|
|
@@ -20,14 +21,14 @@ SCHEMA: dict[str, DataTypeClass] = {
|
|
|
20
21
|
"IDM3": pl.UInt16, # Année fin enquête
|
|
21
22
|
"IDM4": pl.String, # Code Insee ville centre
|
|
22
23
|
"ZFM": pl.String, # zone fine
|
|
23
|
-
"ECH": pl.UInt32, # Numéro d
|
|
24
|
+
"ECH": pl.UInt32, # Numéro d'échantillon
|
|
24
25
|
"GM1": pl.String, # Insee Zone fine
|
|
25
|
-
"STM": pl.String, # Secteur de tirage dans l
|
|
26
|
+
"STM": pl.String, # Secteur de tirage dans l'enquête d'origine
|
|
26
27
|
"M1": pl.UInt8, # TYPE D'HABITAT
|
|
27
28
|
"M2": pl.UInt8, # TYPE D'OCCUPATION
|
|
28
29
|
"M3": pl.UInt8, # POSSESSION DU TELEPHONE
|
|
29
30
|
"M4": pl.UInt8, # Annuaire
|
|
30
|
-
"M5": pl.UInt8, # Disposition d
|
|
31
|
+
"M5": pl.UInt8, # Disposition d'une connexion internet
|
|
31
32
|
"M6": pl.UInt8, # Nombre de VP du ménage
|
|
32
33
|
"M7A": pl.UInt8, # GENRE DU VEHICULE n°1
|
|
33
34
|
"M8A": pl.UInt8, # TYPE D'ENERGIE DU VEHICULE n°1
|
|
@@ -227,7 +228,7 @@ class HouseholdsReader(CeremaReader):
|
|
|
227
228
|
return lf
|
|
228
229
|
|
|
229
230
|
def main_insee(self):
|
|
230
|
-
return self.scan_households().select("IDM4").first().collect().item()
|
|
231
|
+
return self.scan_households().select("IDM4").first().collect().item()
|
|
231
232
|
|
|
232
233
|
def standardize_households(self, skip_insee: bool = False):
|
|
233
234
|
lf = self.scan_households()
|
|
@@ -370,8 +371,8 @@ class HouseholdsReader(CeremaReader):
|
|
|
370
371
|
MOTORCYCLE_THERMIC_ENGINE_TYPE_MAP, default=None
|
|
371
372
|
),
|
|
372
373
|
parking_location=pl.col(f"M19{a}").replace_strict(PARKING_LOCATION_MAP),
|
|
373
|
-
# `default=None` is required because in some surveys (Rennes 2018), other values
|
|
374
|
-
# used without being documented
|
|
374
|
+
# `default=None` is required because in some surveys (Rennes 2018), other values
|
|
375
|
+
# are used without being documented
|
|
375
376
|
parking_type=pl.col(f"M20{a}").replace_strict(PARKING_TYPE_MAP, default=None),
|
|
376
377
|
)
|
|
377
378
|
for i, a in enumerate(("A", "B", "C", "D"))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# ruff: noqa: E501
|
|
1
2
|
import io
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
|
|
@@ -15,14 +16,14 @@ SCHEMA: dict[str, DataTypeClass] = {
|
|
|
15
16
|
"IDP3": pl.UInt16, # Année de fin d'enquête
|
|
16
17
|
"IDP4": pl.String, # Code Insee ville centre
|
|
17
18
|
"ZFP": pl.String, # Zone fine de résidence
|
|
18
|
-
"ECH": pl.UInt32, # Numéro d
|
|
19
|
+
"ECH": pl.UInt32, # Numéro d'échantillon
|
|
19
20
|
"PER": pl.UInt8, # Numéro de personne
|
|
20
21
|
"GP1": pl.String, # Insee Zone fine du lieu de résidence de la personne
|
|
21
|
-
"STP": pl.String, # Secteur de tirage dans l
|
|
22
|
-
"AN": pl.UInt16, # Année du jour d
|
|
23
|
-
"ANNEE": pl.UInt16, # Année du jour d
|
|
24
|
-
"MOIS": pl.UInt8, # Mois du jour d
|
|
25
|
-
"DATE": pl.UInt8, # Jour d
|
|
22
|
+
"STP": pl.String, # Secteur de tirage dans l'enquête d'origine (résidence)
|
|
23
|
+
"AN": pl.UInt16, # Année du jour d'enquête (EMC2)
|
|
24
|
+
"ANNEE": pl.UInt16, # Année du jour d'enquête (EDGT, EDVM, EMD)
|
|
25
|
+
"MOIS": pl.UInt8, # Mois du jour d'enquête
|
|
26
|
+
"DATE": pl.UInt8, # Jour d'enquête
|
|
26
27
|
"JOUR": pl.UInt8, # Jour des déplacements
|
|
27
28
|
"PENQ": pl.UInt8, # Personne enquêtée ?
|
|
28
29
|
"P2": pl.UInt8, # Sexe de la personne
|
|
@@ -31,29 +32,29 @@ SCHEMA: dict[str, DataTypeClass] = {
|
|
|
31
32
|
"P5": pl.UInt8, # Possession d'un téléphone portable
|
|
32
33
|
"P6": pl.UInt8, # Possession d'une adresse de messagerie électronique
|
|
33
34
|
"P7": pl.UInt8, # Possession du permis de conduire voiture
|
|
34
|
-
"P8": pl.UInt8, # Niveau d
|
|
35
|
+
"P8": pl.UInt8, # Niveau d'études
|
|
35
36
|
"P9": pl.UInt8, # Occupation principale de la personne
|
|
36
37
|
"P10": pl.UInt8, # Occupation secondaire
|
|
37
38
|
"PCSC": pl.UInt8, # PCS courte
|
|
38
39
|
"PCSD": pl.UInt8, # PCS détaillée
|
|
39
40
|
"P12": pl.UInt8, # Possession d'un abonnement TC valide hier
|
|
40
41
|
"P14": pl.UInt8, # Travail, études à domicile
|
|
41
|
-
"P15": pl.String, # Zone fine du lieu de travail ou d
|
|
42
|
+
"P15": pl.String, # Zone fine du lieu de travail ou d'études
|
|
42
43
|
"DP15": pl.Float64, # Distance domicile - travail / études à vol d'oiseau
|
|
43
44
|
"GP5": pl.String, # Insee Zone fine du lieu de travail / études
|
|
44
|
-
"STW": pl.String, # Secteur de tirage dans l
|
|
45
|
+
"STW": pl.String, # Secteur de tirage dans l'enquête d'origine (lieu de travail / études)
|
|
45
46
|
"P16": pl.UInt8, # Disposition d'une VP pour se rendre sur le lieu de travail ou d'études
|
|
46
47
|
"P13B": pl.UInt8, # Pratique du télétravail (EMC2 only)
|
|
47
48
|
"P17": pl.UInt8, # Problèmes de stationnement sur le lieu de travail ou d'études (EDGT, EDVM, EMD)
|
|
48
49
|
"P18": pl.UInt8, # Difficultés de stationnement sur le lieu de travail ou d'études
|
|
49
50
|
"P18A": pl.UInt8, # Stationnement du vélo sur le lieu de travail / études
|
|
50
51
|
"P19": pl.UInt8, # Fréquence de déplacement à pied
|
|
51
|
-
"P20": pl.UInt8, # Fréquence d
|
|
52
|
-
"P21": pl.UInt8, # Fréquence d
|
|
53
|
-
"P22": pl.UInt8, # Fréquence d
|
|
54
|
-
"P23": pl.UInt8, # Fréquence d
|
|
55
|
-
"P24": pl.UInt8, # Fréquence d
|
|
56
|
-
"P25": pl.UInt8, # Situation la veille du jour d
|
|
52
|
+
"P20": pl.UInt8, # Fréquence d'utilisation d'un vélo
|
|
53
|
+
"P21": pl.UInt8, # Fréquence d'utilisation d'un deux-roues motorisé
|
|
54
|
+
"P22": pl.UInt8, # Fréquence d'utilisation de la VP en tant que conducteur
|
|
55
|
+
"P23": pl.UInt8, # Fréquence d'utilisation de la VP en tant que passager
|
|
56
|
+
"P24": pl.UInt8, # Fréquence d'utilisation du réseau urbain
|
|
57
|
+
"P25": pl.UInt8, # Situation la veille du jour d'enquête
|
|
57
58
|
"P26": pl.UInt8, # Travail la veille
|
|
58
59
|
"COE1": pl.Float64, # Coefficient de redressement -Toutes Personnes
|
|
59
60
|
"COEP": pl.Float64, # Coefficient de redressement - Personnes Enquêtées
|
|
@@ -81,13 +82,13 @@ EDUCATION_LEVEL_MAP = {
|
|
|
81
82
|
2: "secondary:no_bac", # Secondaire (de la 6e à la 3e, CAP)
|
|
82
83
|
3: "secondary:no_bac", # Secondaire (de la seconde à la terminale, BEP), non titulaire du bac
|
|
83
84
|
4: "secondary:bac", # Secondaire, titulaire du bac
|
|
84
|
-
5: "higher:at_most_bac+2", # Supérieur jusqu
|
|
85
|
+
5: "higher:at_most_bac+2", # Supérieur jusqu'à bac + 2
|
|
85
86
|
6: "higher:at_least_bac+3", # Supérieur, bac + 3 et plus
|
|
86
87
|
# Apprentissage is usually something like CAP so we put secondary:no_bac
|
|
87
88
|
7: "secondary:no_bac", # Apprentissage (école primaire ou secondaire uniquement)
|
|
88
89
|
# Apprentissage (études supérieurs) should rarely be higher than BAC+2
|
|
89
90
|
8: "higher:at_most_bac+2", # Apprentissage (études supérieures)
|
|
90
|
-
9: "no_studies_or_no_diploma", # Pas d
|
|
91
|
+
9: "no_studies_or_no_diploma", # Pas d'études
|
|
91
92
|
# For the two modalities below we have to make an assumption.
|
|
92
93
|
93: "secondary:no_bac", # Secondaire (sans distinction titulaire du bac ou non)
|
|
93
94
|
97: "secondary:no_bac", # Apprentissage (sans distinction)
|
|
@@ -102,11 +103,11 @@ DETAILED_EDUCATION_LEVEL_MAP = {
|
|
|
102
103
|
2: "secondary:no_bac:college", # Secondaire (de la 6e à la 3e, CAP)
|
|
103
104
|
3: "secondary:no_bac:CAP/BEP", # Secondaire (de la seconde à la terminale, BEP), non titulaire du bac
|
|
104
105
|
4: "secondary:bac:unspecified", # Secondaire, titulaire du bac
|
|
105
|
-
5: "higher:at_most_bac+2:unspecified", # Supérieur jusqu
|
|
106
|
+
5: "higher:at_most_bac+2:unspecified", # Supérieur jusqu'à bac + 2
|
|
106
107
|
6: "higher:at_least_bac+3:unspecified", # Supérieur, bac + 3 et plus
|
|
107
108
|
7: "secondary:no_bac:CAP/BEP", # Apprentissage (école primaire ou secondaire uniquement)
|
|
108
109
|
8: "higher:at_most_bac+2:unspecified", # Apprentissage (études supérieures)
|
|
109
|
-
9: "no_studies", # Pas d
|
|
110
|
+
9: "no_studies", # Pas d'études
|
|
110
111
|
93: None, # Secondaire (sans distinction titulaire du bac ou non)
|
|
111
112
|
97: None, # Apprentissage (sans distinction)
|
|
112
113
|
90: None, # autre (egt)
|
|
@@ -167,12 +168,12 @@ PUBLIC_TRANSIT_SUBSCRIPTION_MAP = {
|
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
HAS_CAR_TO_COMMUTE_MAP = {
|
|
170
|
-
1: "yes:full_commute", # Oui et je l
|
|
171
|
-
2: "yes:partial_commute", # Oui mais je ne l
|
|
172
|
-
3: "yes:not_used", # Oui, mais je ne l
|
|
171
|
+
1: "yes:full_commute", # Oui et je l'utilise jusqu'à mon lieu de travail ou d'études
|
|
172
|
+
2: "yes:partial_commute", # Oui mais je ne l'utilise que sur une partie du déplacement
|
|
173
|
+
3: "yes:not_used", # Oui, mais je ne l'utilise pas
|
|
173
174
|
4: "no", # Non
|
|
174
175
|
5: "yes:partial_or_not_used", # Oui, mais je ne l'utilise qu'en partie ou pas du tout (2+3 sans distinction)
|
|
175
|
-
6: "yes:full_or_partial", # Oui et je l
|
|
176
|
+
6: "yes:full_or_partial", # Oui et je l'utilise pour tout ou partie du déplacement (1+2 sans distinction)
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
TELEWORK_MAP = {
|
|
@@ -184,7 +185,7 @@ TELEWORK_MAP = {
|
|
|
184
185
|
|
|
185
186
|
WORK_STUDY_CAR_PARKING_MAP = {
|
|
186
187
|
1: "no", # Non
|
|
187
|
-
2: "yes:reserved", # Oui , car j
|
|
188
|
+
2: "yes:reserved", # Oui , car j'ai (ou pourrai avoir) une place réservée
|
|
188
189
|
3: "yes:many_spots", # Oui, offre importante à proximité
|
|
189
190
|
4: "yes:compatible_schedule", # Oui, compte tenu de mes horaires
|
|
190
191
|
5: "dont_know", # Ne sait pas (EMC2 only)
|
|
@@ -206,7 +207,7 @@ TRAVELED_DAY_BEFORE_MAP = {
|
|
|
206
207
|
2: "no", # Non
|
|
207
208
|
3: "away", # Absent (vieille enquête)
|
|
208
209
|
4: None, # déplacements non relevés
|
|
209
|
-
5: "away", # absent -
|
|
210
|
+
5: "away", # absent - longue durée-
|
|
210
211
|
9: None,
|
|
211
212
|
}
|
|
212
213
|
|
|
@@ -214,7 +215,7 @@ WORKED_DAY_BEFORE_MAP = {
|
|
|
214
215
|
0: None, # Note. Used in some surveys but undefined.
|
|
215
216
|
1: "yes:outside", # Oui, hors du domicile.
|
|
216
217
|
2: "yes:home:usual", # Oui mais à domicile (travail toujours au domicile).
|
|
217
|
-
3: "yes:home:telework", # Oui mais à domicile
|
|
218
|
+
3: "yes:home:telework", # Oui mais à domicile - télétravail.
|
|
218
219
|
4: "yes:home:other", # Oui mais à domicile - autre
|
|
219
220
|
5: "no:weekday", # Non, ne travaille jamais ce jour-là.
|
|
220
221
|
6: "no:reason", # Non en raison de congés, grève ou maladie.
|
|
@@ -113,14 +113,14 @@ class CeremaReader:
|
|
|
113
113
|
"""
|
|
114
114
|
cols = ["ECH", "STM", "ZFM"]
|
|
115
115
|
if self.SURVEY_TYPE == "EMC2":
|
|
116
|
-
return ["METH"
|
|
116
|
+
return ["METH", *cols]
|
|
117
117
|
else:
|
|
118
118
|
return cols
|
|
119
119
|
|
|
120
120
|
def get_person_index_cols(self):
|
|
121
121
|
cols = ["ECH", "STP", "ZFP", "PER"]
|
|
122
122
|
if self.SURVEY_TYPE == "EMC2":
|
|
123
|
-
return ["PMET"
|
|
123
|
+
return ["PMET", *cols]
|
|
124
124
|
else:
|
|
125
125
|
return cols
|
|
126
126
|
|
|
@@ -134,7 +134,7 @@ class CeremaReader:
|
|
|
134
134
|
def get_trip_index_cols(self):
|
|
135
135
|
cols = ["ECH", "STD", "ZFD", "PER", "NDEP"]
|
|
136
136
|
if self.SURVEY_TYPE == "EMC2":
|
|
137
|
-
return ["DMET"
|
|
137
|
+
return ["DMET", *cols]
|
|
138
138
|
else:
|
|
139
139
|
return cols
|
|
140
140
|
|
|
@@ -148,7 +148,7 @@ class CeremaReader:
|
|
|
148
148
|
def get_leg_index_cols(self):
|
|
149
149
|
cols = ["ECH", "STT", "ZFT", "PER", "NDEP"]
|
|
150
150
|
if self.SURVEY_TYPE == "EMC2":
|
|
151
|
-
return ["TMET"
|
|
151
|
+
return ["TMET", cols]
|
|
152
152
|
else:
|
|
153
153
|
return cols
|
|
154
154
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
1
2
|
from datetime import timedelta
|
|
2
|
-
from typing import Callable
|
|
3
3
|
|
|
4
4
|
import geopandas as gpd
|
|
5
5
|
import pandas as pd
|
|
@@ -85,12 +85,12 @@ class CeremaStandardizer(HouseholdsReader, PersonsReader, TripsReader, LegsReade
|
|
|
85
85
|
|
|
86
86
|
def finish(self):
|
|
87
87
|
# Collecting all LazyFrames at this point can speed up next computations.
|
|
88
|
-
self.households = self.households.collect().lazy()
|
|
89
|
-
self.persons = self.persons.collect().lazy()
|
|
90
|
-
self.trips = self.trips.collect().lazy()
|
|
91
|
-
self.legs = self.legs.collect().lazy()
|
|
92
|
-
self.cars = self.cars.collect().lazy()
|
|
93
|
-
self.motorcycles = self.motorcycles.collect().lazy()
|
|
88
|
+
self.households = self.households.collect().lazy()
|
|
89
|
+
self.persons = self.persons.collect().lazy()
|
|
90
|
+
self.trips = self.trips.collect().lazy()
|
|
91
|
+
self.legs = self.legs.collect().lazy()
|
|
92
|
+
self.cars = self.cars.collect().lazy()
|
|
93
|
+
self.motorcycles = self.motorcycles.collect().lazy()
|
|
94
94
|
self.add_survey_dates()
|
|
95
95
|
self.fix_main_mode()
|
|
96
96
|
self.fix_detailed_zones()
|
|
@@ -112,7 +112,7 @@ class CeremaStandardizer(HouseholdsReader, PersonsReader, TripsReader, LegsReade
|
|
|
112
112
|
is_valid_weekday=pl.col("trip_weekday").n_unique() == 1,
|
|
113
113
|
)
|
|
114
114
|
.collect()
|
|
115
|
-
)
|
|
115
|
+
)
|
|
116
116
|
self.households = self.households.join(
|
|
117
117
|
household_dates.lazy(), on="household_id", how="left", coalesce=True
|
|
118
118
|
).with_columns(trips_weekday=pl.when("is_valid_weekday").then(pl.col("trips_weekday")))
|
|
@@ -126,7 +126,7 @@ class CeremaStandardizer(HouseholdsReader, PersonsReader, TripsReader, LegsReade
|
|
|
126
126
|
.filter(pl.col("mode_group").eq(pl.col("main_mode_group")).any().over("trip_id").not_())
|
|
127
127
|
.select("trip_id")
|
|
128
128
|
.collect()
|
|
129
|
-
.to_series()
|
|
129
|
+
.to_series()
|
|
130
130
|
.unique()
|
|
131
131
|
)
|
|
132
132
|
n = len(invalid_trips)
|
|
@@ -144,7 +144,7 @@ class CeremaStandardizer(HouseholdsReader, PersonsReader, TripsReader, LegsReade
|
|
|
144
144
|
.group_by("trip_id")
|
|
145
145
|
.agg(main_mode=pl.col("mode").last(), main_mode_group=pl.col("mode_group").last())
|
|
146
146
|
.collect()
|
|
147
|
-
)
|
|
147
|
+
)
|
|
148
148
|
logger.warning(
|
|
149
149
|
f"For {n} trips, `main_mode_group` value does not appear in any legs'`mode_group`. "
|
|
150
150
|
f"The `main_mode_group` value is automatically fixed."
|
|
@@ -174,26 +174,34 @@ class CeremaStandardizer(HouseholdsReader, PersonsReader, TripsReader, LegsReade
|
|
|
174
174
|
# The detailed zone ids can have various numbers of leading zeros in the CSVs / spatial
|
|
175
175
|
# files. We left-pad all values to the same number of characters to make matching values
|
|
176
176
|
# easier.
|
|
177
|
+
# Note. The `or 0` ensure that if a *_detailed_zone is column is all-NULLs, the max_len will
|
|
178
|
+
# still be properly estimated.
|
|
177
179
|
max_len = max(
|
|
178
|
-
self.detailed_zones["detailed_zone_id"].str.len().max(),
|
|
180
|
+
self.detailed_zones["detailed_zone_id"].str.len().max() or 0,
|
|
179
181
|
self.households.select(pl.col("home_detailed_zone").str.len_chars().max())
|
|
180
182
|
.collect()
|
|
181
|
-
.item()
|
|
182
|
-
|
|
183
|
-
.collect()
|
|
184
|
-
|
|
183
|
+
.item()
|
|
184
|
+
or 0,
|
|
185
|
+
self.persons.select(pl.col("work_detailed_zone").str.len_chars().max()).collect().item()
|
|
186
|
+
or 0,
|
|
185
187
|
self.persons.select(pl.col("study_detailed_zone").str.len_chars().max())
|
|
186
188
|
.collect()
|
|
187
|
-
.item()
|
|
188
|
-
|
|
189
|
-
.collect()
|
|
190
|
-
|
|
189
|
+
.item()
|
|
190
|
+
or 0,
|
|
191
|
+
self.trips.select(pl.col("origin_detailed_zone").str.len_chars().max()).collect().item()
|
|
192
|
+
or 0,
|
|
191
193
|
self.trips.select(pl.col("destination_detailed_zone").str.len_chars().max())
|
|
192
194
|
.collect()
|
|
193
|
-
.item()
|
|
194
|
-
|
|
195
|
-
self.legs.select(pl.col("
|
|
195
|
+
.item()
|
|
196
|
+
or 0,
|
|
197
|
+
self.legs.select(pl.col("start_detailed_zone").str.len_chars().max()).collect().item()
|
|
198
|
+
or 0,
|
|
199
|
+
self.legs.select(pl.col("end_detailed_zone").str.len_chars().max()).collect().item()
|
|
200
|
+
or 0,
|
|
196
201
|
)
|
|
202
|
+
if max_len == 0:
|
|
203
|
+
# Only null values for *_detailed_zone.
|
|
204
|
+
return
|
|
197
205
|
self.detailed_zones["detailed_zone_id"] = self.detailed_zones["detailed_zone_id"].str.pad(
|
|
198
206
|
width=max_len, fillchar="0"
|
|
199
207
|
)
|
|
@@ -394,11 +402,8 @@ def identify_zf_gt_system(
|
|
|
394
402
|
zf_values = set(detailed_zones["detailed_zone_id"].str.slice(-n, m).value_counts().index)
|
|
395
403
|
if not gt_values.intersection(zf_values):
|
|
396
404
|
# ZF / GT can be identified through the n-th character before end.
|
|
397
|
-
return (
|
|
398
|
-
|
|
399
|
-
.str.slice(-n, 1)
|
|
400
|
-
.is_in(gt_values)
|
|
401
|
-
.not_()
|
|
405
|
+
return lambda prefix: (
|
|
406
|
+
pl.col(f"{prefix}_detailed_zone").str.slice(-n, 1).is_in(gt_values).not_()
|
|
402
407
|
)
|
|
403
408
|
# For some surveys, all detailed zone ids end with "000", while all special location ids do
|
|
404
409
|
# not end with "000".
|
|
@@ -410,8 +415,8 @@ def identify_zf_gt_system(
|
|
|
410
415
|
and (special_locations["special_location_id"].str.slice(-3) == "000").sum() == 1
|
|
411
416
|
):
|
|
412
417
|
# Special case for Niort 2016: there is a special location with id "00000000".
|
|
413
|
-
return (
|
|
414
|
-
|
|
418
|
+
return lambda prefix: (
|
|
419
|
+
pl.col(f"{prefix}_detailed_zone").str.slice(-3).eq("000")
|
|
415
420
|
& pl.col(f"{prefix}_detailed_zone").str.contains("^0+$").not_()
|
|
416
421
|
)
|
|
417
422
|
# For Quimper 2013 (and maybe others), the detailed zone ids ends with "00x" or "01x" but
|
|
@@ -16,21 +16,21 @@ SCHEMA: dict[str, DataTypeClass] = {
|
|
|
16
16
|
"IDT3": pl.UInt16, # Année de fin d'enquête
|
|
17
17
|
"IDT4": pl.String, # Code Insee ville centre
|
|
18
18
|
"ZFT": pl.String, # Zone fine de résidence
|
|
19
|
-
"ECH": pl.UInt32, # Numéro d
|
|
19
|
+
"ECH": pl.UInt32, # Numéro d'échantillon
|
|
20
20
|
"PER": pl.UInt8, # Numéro de personne
|
|
21
21
|
"NDEP": pl.UInt8, # Numéro de déplacement
|
|
22
22
|
"T1": pl.UInt8, # Numéro de trajet
|
|
23
23
|
"GT1": pl.String, # Insee Zone fine du lieu de résidence de la personne concernée par le trajet
|
|
24
|
-
"STT": pl.String, # Secteur de tirage dans l
|
|
24
|
+
"STT": pl.String, # Secteur de tirage dans l'enquête d'origine (résidence)
|
|
25
25
|
"T2": pl.Int32, # Temps de marche à pied au départ
|
|
26
26
|
"T3": pl.UInt8, # Mode utilisé
|
|
27
27
|
"T4": pl.String, # Zone fine de départ du mode mécanisé
|
|
28
28
|
"GTO1": pl.String, # Insee Zone fine Origine du trajet
|
|
29
|
-
"STTO": pl.String, # Secteur de tirage dans l
|
|
29
|
+
"STTO": pl.String, # Secteur de tirage dans l'enquête d'origine (origine du trajet)
|
|
30
30
|
"T5": pl.String, # Zone fine d'arrivée du mode mécanisé
|
|
31
31
|
"GTD1": pl.String, # Insee Zone fine Destination du trajet
|
|
32
|
-
"STTD": pl.String, # Secteur de tirage dans l
|
|
33
|
-
"T6": pl.Int32, # Temps de marche à pied à l
|
|
32
|
+
"STTD": pl.String, # Secteur de tirage dans l'enquête d'origine (destination du trajet)
|
|
33
|
+
"T6": pl.Int32, # Temps de marche à pied à l'arrivée
|
|
34
34
|
"T7": pl.UInt8, # Numéro du véhicule
|
|
35
35
|
"T3A": pl.UInt8, # Voiture sans permis (EMC2 only)
|
|
36
36
|
"T8": pl.UInt8, # Nombre de personnes total
|
|
@@ -39,7 +39,7 @@ SCHEMA: dict[str, DataTypeClass] = {
|
|
|
39
39
|
"T9": pl.UInt8, # Lieu de stationnement
|
|
40
40
|
"T10": pl.UInt8, # Nature du stationnement
|
|
41
41
|
"T11": pl.UInt16, # Durée de recherche du stationnement
|
|
42
|
-
"T12": pl.Float64, # Longueur à vol d
|
|
42
|
+
"T12": pl.Float64, # Longueur à vol d'oiseau
|
|
43
43
|
"T13": pl.Float64, # Distance parcourue
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -147,9 +147,10 @@ class LegsReader(CeremaReader):
|
|
|
147
147
|
# We create actual walking legs from these walking times.
|
|
148
148
|
|
|
149
149
|
# Part 1: walking leg from origin
|
|
150
|
-
# The walking leg from origin is read from the start walking time of the first leg of each
|
|
151
|
-
#
|
|
152
|
-
#
|
|
150
|
+
# The walking leg from origin is read from the start walking time of the first leg of each
|
|
151
|
+
# trip.
|
|
152
|
+
# The origin is set to the origin of the trip. The destination is set to the start point of
|
|
153
|
+
# the first leg.
|
|
153
154
|
# The trip index is set to 1.
|
|
154
155
|
lf1 = (
|
|
155
156
|
lf.filter(pl.col("T1") == 1, pl.col("T2") > 0)
|
|
@@ -166,7 +167,7 @@ class LegsReader(CeremaReader):
|
|
|
166
167
|
)
|
|
167
168
|
.with_columns(
|
|
168
169
|
original_leg_id=pl.struct(
|
|
169
|
-
self.get_leg_index_cols()
|
|
170
|
+
[*self.get_leg_index_cols(), pl.lit(None, dtype=pl.UInt8).alias("T1")]
|
|
170
171
|
),
|
|
171
172
|
tmp_leg_index=pl.lit(1, dtype=pl.UInt8),
|
|
172
173
|
mode=pl.lit("walking"),
|
|
@@ -188,7 +189,7 @@ class LegsReader(CeremaReader):
|
|
|
188
189
|
"T11": "parking_search_time",
|
|
189
190
|
}
|
|
190
191
|
).with_columns(
|
|
191
|
-
original_leg_id=pl.struct(self.get_leg_index_cols()
|
|
192
|
+
original_leg_id=pl.struct([*self.get_leg_index_cols(), "T1"]),
|
|
192
193
|
tmp_leg_index=2 * pl.col("T1"),
|
|
193
194
|
mode=pl.col("T3").replace_strict(self.get_mode_map()),
|
|
194
195
|
nolicense_car=pl.col("T3A") == 1,
|
|
@@ -199,12 +200,12 @@ class LegsReader(CeremaReader):
|
|
|
199
200
|
)
|
|
200
201
|
# Part 3: walking legs after actual legs
|
|
201
202
|
# The remaining walking leg are read from the end walking time of each leg.
|
|
202
|
-
# The origin is set to the end point of the leg. The destination is set to the start point
|
|
203
|
-
# the next leg (or to the trip's destination if there is no leg after).
|
|
203
|
+
# The origin is set to the end point of the leg. The destination is set to the start point
|
|
204
|
+
# of the next leg (or to the trip's destination if there is no leg after).
|
|
204
205
|
# The trip index is set to twice the original trip index + 1, i.e., 3, 5, 7, etc.
|
|
205
|
-
# NOTE. The end walking time of the leg is supposed to be equal to the start walking time of
|
|
206
|
-
# next leg. In practise, this rule is not respected in some rare cases. Here, we do not
|
|
207
|
-
# that rule and we use directly the end walking time.
|
|
206
|
+
# NOTE. The end walking time of the leg is supposed to be equal to the start walking time of
|
|
207
|
+
# the next leg. In practise, this rule is not respected in some rare cases. Here, we do not
|
|
208
|
+
# check that rule and we use directly the end walking time.
|
|
208
209
|
lf3 = (
|
|
209
210
|
lf.filter(pl.col("T6") > 0)
|
|
210
211
|
.rename(
|
|
@@ -217,7 +218,7 @@ class LegsReader(CeremaReader):
|
|
|
217
218
|
)
|
|
218
219
|
.with_columns(
|
|
219
220
|
original_leg_id=pl.struct(
|
|
220
|
-
self.get_leg_index_cols()
|
|
221
|
+
[*self.get_leg_index_cols(), pl.lit(None, dtype=pl.UInt8).alias("T1")]
|
|
221
222
|
),
|
|
222
223
|
tmp_leg_index=2 * pl.col("T1") + 1,
|
|
223
224
|
mode=pl.lit("walking"),
|
|
@@ -93,7 +93,7 @@ def select_columns(gdf: gpd.GeoDataFrame, cols: tuple[str, ...]):
|
|
|
93
93
|
"""Given a tuple of column names, return the list of columns which are present in the
|
|
94
94
|
GeoDataFrame.
|
|
95
95
|
"""
|
|
96
|
-
return ["geometry"
|
|
96
|
+
return ["geometry", *filter(lambda c: c in gdf.columns, cols)]
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
class ZonesReader(CeremaReader):
|