Fix #3: replace empty string with np.nan
This commit is contained in:
parent
2761c3ed7b
commit
f9be31c090
@ -83,6 +83,5 @@ def table2df(tables):
|
|||||||
df = pd.concat(dfs)
|
df = pd.concat(dfs)
|
||||||
|
|
||||||
df["immeuble"] = df["immeuble"].apply(lambda x: x[0].capitalize())
|
df["immeuble"] = df["immeuble"].apply(lambda x: x[0].capitalize())
|
||||||
print(df.columns)
|
|
||||||
df["lot"] = df["RECAPITULATIF DES OPERATIONS"].apply(get_lot)
|
df["lot"] = df["RECAPITULATIF DES OPERATIONS"].apply(get_lot)
|
||||||
return df.astype(DF_TYPES, errors="ignore")
|
return df.astype(DF_TYPES)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
DF_TYPES = {
|
DF_TYPES = {
|
||||||
@ -33,7 +34,7 @@ def is_drop(row):
|
|||||||
|
|
||||||
|
|
||||||
def extract(table, additionnal_fields: dict = {}):
|
def extract(table, additionnal_fields: dict = {}):
|
||||||
"""Turn table to dictionary with additionnal fields"""
|
"""Turn table to dictionary with additional fields"""
|
||||||
extracted = []
|
extracted = []
|
||||||
header = table[0]
|
header = table[0]
|
||||||
for row in table[1:]:
|
for row in table[1:]:
|
||||||
@ -159,4 +160,7 @@ def table2df(tables):
|
|||||||
df["immeuble"] = df["immeuble"].apply(lambda x: x[0].capitalize())
|
df["immeuble"] = df["immeuble"].apply(lambda x: x[0].capitalize())
|
||||||
df["Type"] = df["Type"].apply(clean_type)
|
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)
|
||||||
|
|
||||||
|
return df.astype(DF_TYPES)
|
||||||
|
Loading…
Reference in New Issue
Block a user