Feat: add lot for charges

This commit is contained in:
Bertrand Benjamin 2022-09-28 21:03:53 +02:00
parent 67bea5b9b4
commit 1883df5999

View File

@ -4,10 +4,19 @@ import numpy as np
import pandas as pd import pandas as pd
def get_lot(x):
"""Return lot number from "RECAPITULATIF DES OPERATIONS" """
if x[:2].isdigit():
return x[:2]
if x[:1].isdigit():
return "0" + x[:1]
if x[:2] == "PC":
return "PC"
return ""
def extract_charge(table): def extract_charge(table):
"""From pdfplumber table extract the charge dataframe""" """From pdfplumber table extract the charge dataframe"""
for l in table:
print(l)
df = ( df = (
pd.DataFrame(table[1:], columns=table[0]) pd.DataFrame(table[1:], columns=table[0])
.replace("", np.nan) .replace("", np.nan)
@ -26,6 +35,8 @@ def extract_charge(table):
inplace=True, inplace=True,
) )
df = df.assign(lot=df["RECAPITULATIF DES OPERATIONS"].map(get_lot))
df = df.astype( df = df.astype(
{ {
"Débits": "float64", "Débits": "float64",