開始使用免費開始

建立 Dask bag

你被指派要分析一些 TripAdvisor 上的評論。你的同事把這些評論整理成字串清單。你想使用 Dask 來加速資料分析,因此第一步需要把資料載入成一個 Dask bag。

本練習屬於課程

在 Python 中使用 Dask 進行平行程式設計

檢視課程

練習說明

  • dask.bag 子套件匯入為 db
  • 使用 from_sequence() 函式把 reviews_list 轉換為有 3 個分割區的 Dask bag。
  • 使用該 bag 的 .take() 方法列印其中一個元素。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import the Dask bag subpackage as db
____

# Convert the list to a Dask bag
review_bag = db.____(____, ____=____)

# Print 1 element of the bag
print(____)
編輯並執行程式碼