Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
lga
crater-data
Commits
f2c8982f
Commit
f2c8982f
authored
Nov 12, 2021
by
Lionel DURAND
Browse files
Vectorisation calcul note politique foncière
parent
01e65f50
Changes
2
Hide whitespace changes
Inline
Side-by-side
crater/politique_fonciere/synthese_politique_fonciere.py
View file @
f2c8982f
...
...
@@ -36,30 +36,13 @@ def _ajouter_colonne_message_synthese(donnees_politique_fonciere):
def
_ajouter_colonne_synthese_note
(
donnees_politique_fonciere
):
donnees_politique_fonciere
.
loc
[:,
'synthese_note'
]
=
(
donnees_politique_fonciere
.
apply
(
lambda
x
:
_note
(
x
[
'sau_par_habitant_note'
],
x
[
'rythme_artificialisation_sau_note'
]
),
axis
=
1
)
)
donnees_politique_fonciere
.
loc
[:,
'synthese_note'
]
=
(
(
donnees_politique_fonciere
[
'sau_par_habitant_note'
]
+
donnees_politique_fonciere
[
'rythme_artificialisation_sau_note'
])
/
2
).
round
(
0
)
return
donnees_politique_fonciere
def
_note
(
sau_par_habitant_note
,
rythme_artificialisation_sau_note
):
try
:
x
=
round
((
sau_par_habitant_note
+
rythme_artificialisation_sau_note
)
/
2
,
0
)
except
:
x
=
np
.
nan
return
x
def
_message
(
sau_par_habitant_valeur_m2_par_hab
,
artificialisation_2011_2016_ha
,
...
...
tests/test_unitaire_politique_fonciere.py
View file @
f2c8982f
...
...
@@ -23,16 +23,21 @@ class TestUnitairePolitiqueFonciere(unittest.TestCase):
# given
df_politique_fonciere
=
pd
.
DataFrame
(
columns
=
[
'sau_par_habitant_note'
,
'rythme_artificialisation_sau_note'
],
data
=
[[
9
,
2
]
data
=
[[
9
,
2
],
[
np
.
nan
,
2
],
[
9
,
np
.
nan
]
])
resultat_attendu
=
pd
.
Series
(
data
=
[
6.0
data
=
[
6.0
,
np
.
nan
,
np
.
nan
],
dtype
=
'float64'
)
# when
df_resultat
=
_ajouter_colonne_synthese_note
(
df_politique_fonciere
)
# then
pd
.
testing
.
assert_series_equal
(
df_resultat
[
'synthese_note'
],
resultat_attendu
,
check_names
=
False
)
np
.
testing
.
assert_array_equal
(
resultat_attendu
.
tolist
(),
df_resultat
[
'synthese_note'
].
tolist
())
self
.
assertEqual
(
resultat_attendu
.
dtype
,
df_resultat
[
'synthese_note'
].
dtype
)
def
test_message_synthese_politique_fonciere
(
self
):
# given
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment