lazy loading

Optimiser l'import d'un fichier lourd en utilisant le stockage en binaire après le premier import.

Aussi un cas pratique d'utilisation de **kwargs. One ne connait pas à l'avance si on a des skiprows, nrows .... etc

def extract_data(file_pathname, **kwargs):
    
    try:
        with open("file_pathname[:-4].pkl", "rb") as handle:
            df = pd.read_pickle(handle)
        print("[+] data read from pickle file")
        return df
    
    except FileNotFoundError:
        print("[-] pickle was not found so read from excel and save to pickle")
        
        df = pd.read_excel(file_pathname, **kwargs)
        df.to_pickle("file_pathname[:-4].pkl")
    
        return df