BaşlayınÜcretsiz başlayın

Querying DuckDB into Polars

The team also has a local DuckDB analytical store. A connection is already open, and a physical_format_summary table is loaded for you. DuckDB has its own integration with Polars: query the table and convert the result to a Polars DataFrame in one step.

polars is loaded as pl, and the DuckDB connection is in db.

Bu egzersiz, kursun bir parçasıdır

Scaling and Optimizing Data Pipelines with Polars

Kursa Göz Atın

Egzersiz talimatları

  • Run the SQL query on the DuckDB connection.
  • Convert the DuckDB result to a Polars DataFrame.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Run the query and convert the result to a Polars DataFrame
result = db.____(
    """
    SELECT *
    FROM physical_format_summary
    ORDER BY total_checkouts DESC
    """
).____()
print(result)
Kodu Düzenle ve Çalıştır