2 Commits

2 changed files with 9 additions and 6 deletions

View File

@@ -83,6 +83,5 @@ def table2df(tables):
df = pd.concat(dfs)
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")
return df.astype(DF_TYPES)

View File

@@ -1,3 +1,4 @@
import numpy as np
import pandas as pd
DF_TYPES = {
@@ -33,7 +34,7 @@ def is_drop(row):
def extract(table, additionnal_fields: dict = {}):
"""Turn table to dictionary with additionnal fields"""
"""Turn table to dictionary with additional fields"""
extracted = []
header = table[0]
for row in table[1:]:
@@ -138,8 +139,6 @@ def join_row(table):
}
)
joined.append(row)
else:
pass
return joined
@@ -159,4 +158,9 @@ def table2df(tables):
df["immeuble"] = df["immeuble"].apply(lambda x: x[0].capitalize())
df["Type"] = df["Type"].apply(clean_type)
return df.astype(DF_TYPES, errors="ignore")
numeric_cols = [k for k, v in DF_TYPES.items() if v == float]
df[numeric_cols] = df[numeric_cols].replace("", np.nan)
df = df.drop(df[(df["Locataires"] == "") & (df["Période"] == "")].index)
return df.astype(DF_TYPES)