ComenzarEmpieza gratis

Practice logging

The following code is executed on startup:

import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG,
                    format='%(levelname)s - %(message)s')

You will now practice these logging operations.

Este ejercicio forma parte del curso

Introduction to Spark SQL in Python

Ver curso

Instrucciones del ejercicio

  • Log columns of text_df as debug message.
  • Log whether table1 is cached as info message.
  • Log first row of text_df as warning message.
  • Log selected columns of text_df as error message.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Log columns of text_df as debug message
____("text_df columns: %s", text_df.columns)

# Log whether table1 is cached as info message
____("table1 is cached: %s", spark.catalog.isCached(tableName="table1"))

# Log first row of text_df as warning message
____("The first row of text_df:\n %s", text_df.first())

# Log selected columns of text_df as error message
____("Selected columns: %s", text_df.select("id", "word"))
Editar y ejecutar código