ComenzarEmpieza gratis

Replacing missing values

You are preparing data for a machine learning model. In this case, you don't want to drop rows with missing values, instead you want to replace them with different approaches for different kinds of columns.

The spotify_df DataFrame is available for you.

Este ejercicio forma parte del curso

Introduction to Polars

Ver curso

Instrucciones del ejercicio

  • Replace null values in the "streams" column with the .mean() of the "streams" column.
  • Replace null values in the "title" column with the string "Unknown".

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

filled_streams_df = spotify_df.with_columns(
    # Replace nulls in streams column
    ____,
    # Replace nulls in title column
    ____,
)

print(filled_streams_df)
Editar y ejecutar código