Rétablissement de la carte des marchés par dpt
This commit is contained in:
@@ -106,6 +106,11 @@ a.nav {
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 36px 0 24px 0;
|
||||
}
|
||||
|
||||
summary > h3 {
|
||||
margin: 0;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -32,11 +32,11 @@ def get_map_count_marches(lf: pl.LazyFrame):
|
||||
df,
|
||||
geojson=departements,
|
||||
locations="Département",
|
||||
# color="uid",
|
||||
# color_continuous_scale="Reds",
|
||||
color="uid",
|
||||
color_continuous_scale="Reds",
|
||||
title="Nombres de marchés attribués par département (lieu d'exécution)",
|
||||
# range_color=(df["uid"].min(), df["uid"].max()),
|
||||
# labels={"uid": "Marchés attribués"},
|
||||
range_color=(df["uid"].min(), df["uid"].max()),
|
||||
labels={"uid": "Marchés attribués"},
|
||||
scope="europe",
|
||||
width=1000,
|
||||
height=800,
|
||||
|
||||
@@ -140,7 +140,7 @@ def update_acheteur_stats(data):
|
||||
df = pl.DataFrame(data)
|
||||
if df.height == 0:
|
||||
df = pl.DataFrame(schema=lf.collect_schema())
|
||||
df_marches = df.unique("uid")
|
||||
df_marches = df.unique("id")
|
||||
nb_marches = format_number(df_marches.height)
|
||||
# somme_marches = format_number(int(df_marches.select(pl.sum("montant")).item()))
|
||||
marches_attribues = [html.Strong(nb_marches), " marchés et accord-cadres attribués"]
|
||||
@@ -165,8 +165,9 @@ def update_acheteur_stats(data):
|
||||
def get_acheteur_marches_data(url, acheteur_year: str) -> pl.LazyFrame:
|
||||
acheteur_siret = url.split("/")[-1]
|
||||
lff = lf.filter(pl.col("acheteur_id") == acheteur_siret)
|
||||
lff = lff.fill_null("")
|
||||
lff = lff.select(
|
||||
"uid",
|
||||
"id",
|
||||
"objet",
|
||||
"dateNotification",
|
||||
"titulaire_id",
|
||||
@@ -179,7 +180,7 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> pl.LazyFrame:
|
||||
lff = lff.filter(
|
||||
pl.col("dateNotification").cast(pl.String).str.starts_with(acheteur_year)
|
||||
)
|
||||
lff = lff.sort("dateNotification", descending=True, nulls_last=True)
|
||||
lff = lff.sort(["dateNotification", "id"], descending=True, nulls_last=True)
|
||||
|
||||
data = lff.collect(engine="streaming").to_dicts()
|
||||
return data
|
||||
@@ -191,7 +192,7 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> pl.LazyFrame:
|
||||
)
|
||||
def get_last_marches_table(data) -> html.Div:
|
||||
columns = [
|
||||
"uid",
|
||||
"id",
|
||||
"objet",
|
||||
"dateNotification",
|
||||
"titulaire_nom",
|
||||
|
||||
+3
-19
@@ -8,7 +8,6 @@ from dotenv import load_dotenv
|
||||
from src.utils import (
|
||||
add_org_links,
|
||||
add_resource_link,
|
||||
booleans_to_strings,
|
||||
filter_table_data,
|
||||
format_number,
|
||||
lf,
|
||||
@@ -20,19 +19,6 @@ load_dotenv()
|
||||
update_date = os.path.getmtime(os.getenv("DATA_FILE_PARQUET_PATH"))
|
||||
update_date = datetime.fromtimestamp(update_date).strftime("%d/%m/%Y")
|
||||
|
||||
# Suppression des colonnes inutiles
|
||||
lf = lf.drop(
|
||||
[
|
||||
"donneesActuelles",
|
||||
]
|
||||
)
|
||||
|
||||
# Convertir les colonnes booléennes en chaînes de caractères
|
||||
lf = booleans_to_strings(lf)
|
||||
|
||||
# Remplacer les valeurs manquantes par des chaînes vides
|
||||
lf = lf.fill_null("")
|
||||
|
||||
schema = lf.collect_schema()
|
||||
|
||||
|
||||
@@ -164,14 +150,12 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
||||
if len(sort_by) > 0:
|
||||
lff = sort_table_data(lff, sort_by)
|
||||
|
||||
# Remplace les strings null par "", mais pas les numeric null
|
||||
lff = lff.fill_null("")
|
||||
|
||||
# Matérialisation des filtres
|
||||
dff: pl.DataFrame = lff.collect()
|
||||
|
||||
# if filter_query or sort_by:
|
||||
# filtered_data = dff.to_dicts()
|
||||
# else:
|
||||
# filtered_data = {}
|
||||
|
||||
height = dff.height
|
||||
|
||||
nb_rows = f"{format_number(height)} lignes"
|
||||
|
||||
+9
-2
@@ -126,10 +126,17 @@ def get_decp_data() -> pl.LazyFrame:
|
||||
lff: pl.LazyFrame = pl.scan_parquet(os.getenv("DATA_FILE_PARQUET_PATH"))
|
||||
|
||||
# Tri des marchés par date de notification
|
||||
lff = lff.sort(by=["dateNotification"], descending=True, nulls_last=True)
|
||||
lff = lff.sort(by=["dateNotification", "uid"], descending=True, nulls_last=True)
|
||||
|
||||
# Uniquement les données actuelles, pas les anciennes versions de marchés
|
||||
lff = lff.filter(pl.col("donneesActuelles"))
|
||||
lff = lff.filter(pl.col("donneesActuelles")).drop("donneesActuelles")
|
||||
|
||||
# Convertir les colonnes booléennes en chaînes de caractères
|
||||
lff = booleans_to_strings(lff)
|
||||
|
||||
# Bizarrement je ne peux pas faire lff = lff.fill_null("") ici
|
||||
# ça génère une erreur dans la page acheteur (acheteur_data.table) :
|
||||
# AttributeError: partially initialized module 'pandas' has no attribute 'NaT' (most likely due to a circular import)
|
||||
|
||||
return lff
|
||||
|
||||
|
||||
Reference in New Issue
Block a user