Feat: remove Appartement in type

This commit is contained in:
Bertrand Benjamin 2023-06-28 10:44:56 +02:00
parent 223f25130d
commit 44d4150910
2 changed files with 19 additions and 6 deletions

View File

@ -62,8 +62,6 @@ def extract(table, additionnal_fields: dict = {}):
for k, v in additionnal_fields.items(): for k, v in additionnal_fields.items():
r[k] = v r[k] = v
r["lot"] = get_lot(row[RECAPITULATIF_DES_OPERATIONS])
if "honoraire" in row[RECAPITULATIF_DES_OPERATIONS]: if "honoraire" in row[RECAPITULATIF_DES_OPERATIONS]:
r["Fournisseur"] = "IMI GERANCE" r["Fournisseur"] = "IMI GERANCE"
@ -82,5 +80,9 @@ def table2df(tables):
) )
df["Fournisseur"] = df["Fournisseur"].fillna(method="ffill") df["Fournisseur"] = df["Fournisseur"].fillna(method="ffill")
dfs.append(df) dfs.append(df)
df = pd.concat(dfs).astype(DF_TYPES, errors="ignore") df = pd.concat(dfs)
return df
df["immeuble"] = df["immeuble"].apply(lambda x: x[0].capitalize())
print(df.columns)
df["lot"] = df["RECAPITULATIF DES OPERATIONS"].apply(get_lot)
return df.astype(DF_TYPES, errors="ignore")

View File

@ -84,6 +84,12 @@ def parse_lot(string):
return {"Lot": "{:02d}".format(int(words[1])), "Type": " ".join(words[2:])} return {"Lot": "{:02d}".format(int(words[1])), "Type": " ".join(words[2:])}
def clean_type(string):
if "appartement" in string.lower():
return string[-2:]
return string
def join_row(table): def join_row(table):
joined = [] joined = []
for row in table: for row in table:
@ -133,7 +139,7 @@ def join_row(table):
) )
joined.append(row) joined.append(row)
else: else:
print(row) pass
return joined return joined
@ -148,4 +154,9 @@ def flat_tables(tables):
def table2df(tables): def table2df(tables):
tables = flat_tables(tables) tables = flat_tables(tables)
joined = join_row(tables) joined = join_row(tables)
return pd.DataFrame.from_records(joined).astype(DF_TYPES, errors="ignore") df = pd.DataFrame.from_records(joined)
df["immeuble"] = df["immeuble"].apply(lambda x: x[0].capitalize())
df["Type"] = df["Type"].apply(clean_type)
return df.astype(DF_TYPES, errors="ignore")