Feat: add lot for charges

This commit is contained in:
Bertrand Benjamin 2022-09-28 21:03:53 +02:00
parent 67bea5b9b4
commit 1883df5999
1 changed files with 13 additions and 2 deletions

View File

@ -4,10 +4,19 @@ import numpy as np
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):
"""From pdfplumber table extract the charge dataframe"""
for l in table:
print(l)
df = (
pd.DataFrame(table[1:], columns=table[0])
.replace("", np.nan)
@ -26,6 +35,8 @@ def extract_charge(table):
inplace=True,
)
df = df.assign(lot=df["RECAPITULATIF DES OPERATIONS"].map(get_lot))
df = df.astype(
{
"Débits": "float64",