LoslegenKostenlos starten

Converting column data types

You're building a beauty product recommendation app and need to analyze customer reviews. The dataset contains ratings from 1 to 5, but they're stored as floating-point numbers in the CSV file. To filter reviews by exact rating values, you'll need to convert them to whole numbers first.

polars is loaded as pl. The DataFrame reviews is available with columns including category, detail, review, rating, size, and price.

Diese Übung ist Teil des Kurses

<Kurs>Data Transformation with Polars</Kurs>
Kurs ansehen

Übungsanweisungen

  • Convert the rating column to integers.

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Convert the rating column to integers
reviews.with_columns(
    pl.____("rating").____(pl.Int64)
)
Code bearbeiten und ausführen