ComeçarComece gratuitamente

Registro em um pipeline de dados

Neste exercício, vamos dar uma olhada na função que você escreveu em um vídeo anterior e praticar a adição de registro à função. Isso ajudará você a solucionar erros ou fazer alterações na lógica!

pandas foi importado como pd. Além disso, o módulo logging foi importado e o nível de registro padrão foi definido como "debug".

Este exercício faz parte do curso

ETL e ELT em Python

Ver Curso

Instruções de exercício

  • Crie um registro de nível de informação após a transformação, passando a string: "Transformed 'Order Date' column to type 'datetime'."
  • Registre o .shape do DataFrame no nível de depuração antes e depois da filtragem.

Exercício interativo prático

Experimente este exercício preenchendo este código de exemplo.

def transform(raw_data):
    raw_data["Order Date"] = pd.to_datetime(raw_data["Order Date"], format="%m/%d/%y %H:%M")
    clean_data = raw_data.loc[raw_data["Price Each"] < 10, :]
    
    # Create an info log regarding transformation
    logging.____("Transformed 'Order Date' column to type 'datetime'.")
    
    # Create debug-level logs for the DataFrame before and after filtering
    ____(f"Shape of the DataFrame before filtering: {raw_data.shape}")
    ____(f"Shape of the DataFrame after filtering: {clean_data.shape}")
    
    return clean_data
  
clean_sales_data = transform(raw_sales_data)
Editar e executar código