Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
leximpact-dotations-back
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Simulateur dotations aux communes
leximpact-dotations-back
Commits
a5af3c08
Commit
a5af3c08
authored
4 months ago
by
clallemand
Browse files
Options
Downloads
Patches
Plain Diff
Ajoute gestion des valeurs non communiqué dans les booléens
parent
1cacdce7
No related branches found
No related tags found
1 merge request
!16
Corrections data 2024
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
leximpact_dotations_back/data_building/adapt_dotations_criteres.py
+10
-5
10 additions, 5 deletions
..._dotations_back/data_building/adapt_dotations_criteres.py
with
10 additions
and
5 deletions
leximpact_dotations_back/data_building/adapt_dotations_criteres.py
+
10
−
5
View file @
a5af3c08
...
...
@@ -11,7 +11,8 @@ from leximpact_dotations_back.mapping.valeurs_dgcl import (
DGCL_VALUE__NON_DISPONIBLE_BEFORE_2024
,
DGCL_VALUE__NON_DISPONIBLE_2024
,
DGCL_VALUE_STRING_TRUE_BEFORE_2024
,
DGCL_VALUE_STRING_TRUE_PATTERN_BEFORE_2024
,
DGCL_VALUE_STRING_TRUE
,
DGCL_VALUE_STRING_FALSE
DGCL_VALUE_STRING_TRUE
,
DGCL_VALUE_STRING_FALSE
,
DGCL_VALUE__NON_COMMUNIQUE
)
from
leximpact_dotations_back.mapping.criteres_dgcl_2024
import
(
# noqa: F401
colonnes_utiles_2024
,
# TODO avoid this variable name inference in 'adapt_criteres'
...
...
@@ -301,9 +302,9 @@ def convert_cols_to_real_bool(data, bool_col_list, year):
# Toute année - Les colonnes qui contiennent soit 1 soit le code commune lorsque vrai
else
:
data
[
col
]
=
data
[
col
].
replace
(
DGCL_VALUE__NON_DISPONIBLE
,
DGCL_VALUE_STRING_FALSE
).
copy
()
data
[
col
]
=
data
[
col
].
replace
(
"
n.c
"
,
DGCL_VALUE_STRING_FALSE
).
copy
()
data
[
col
]
=
data
[
col
].
replace
(
DGCL_VALUE__NON_COMMUNIQUE
,
DGCL_VALUE_STRING_FALSE
).
copy
()
data
[
col
].
replace
(
to_replace
=
r
"
^\d{5}$
"
,
value
=
DGCL_VALUE_STRING_TRUE
,
regex
=
True
)
data
[
col
]
=
data
[
col
].
astype
(
bool
)
data
[
col
]
=
data
[
col
].
astype
(
int
).
astype
(
bool
)
# Les colonnes qui contiennent soit 0 ou 1 et de type int
else
:
...
...
@@ -432,6 +433,8 @@ def adapt_criteres(year: int, data: DataFrame, data_insee_communes_history: Data
montant_commune_eligible
=
colonnes_utiles
[
"
montant_commune_eligible
"
]
part_pfi
=
colonnes_utiles
[
"
part_pfi
"
]
extracolumns
[
"
dotation_globale_fonctionnement_reference_communes
"
]
=
colonnes_utiles
[
"
dotation_globale_fonctionnement_reference_communes
"
]
translation_cols
=
{
**
variables_openfisca_presentes_fichier
,
**
extracolumns
}
# TODO: check why data_cleanup.py applied format is lost on "montant_commune_eligible" and "part_pfi"
...
...
@@ -464,13 +467,15 @@ def adapt_criteres(year: int, data: DataFrame, data_insee_communes_history: Data
# Passe les "booléens dgf" (oui/non) en booléens normaux
liste_columns_to_real_bool
=
[
"
zone_de_montagne
"
,
"
insulaire
"
,
"
bureau_centralisateur
"
,
"
chef_lieu_arrondissement
"
,
"
chef_lieu_de_canton
"
,
"
chef_lieu_departement_dans_agglomeration
"
,
"
zrr
"
,
"
zone_de_mont
ag
n
e
"
,
"
insulair
e
"
,
"
dotation_communes_nouvelles_eligible_part_amorc
age
"
,
"
dotation_communes_nouvelles_eligible_part_garanti
e
"
]
data
=
convert_cols_to_real_bool
(
data
,
liste_columns_to_real_bool
,
year
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment