開始使用免費開始

從 parquet 檔案擷取資料

從來源系統擷取資料最常見的方式之一,就是讀取檔案,例如 CSV 檔。隨著資料量變大,更好的檔案格式變得重要,因此出現了像 parquet 這樣的欄式檔案格式。

在這個練習中,你將練習從 parquet 檔案擷取資料。

本練習屬於課程

使用 Python 的 ETL 與 ELT

檢視課程

練習說明

  • 將路徑為 "sales_data.parquet" 的 parquet 檔讀入 pandas 的 DataFrame。
  • 透過 print() 檢查 DataFrame 的資料型別。
  • 輸出 DataFrame 的形狀以及它的前幾列。

動手互動練習

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

import pandas as pd

# Read the sales data into a DataFrame
sales_data = pd.____("____", engine="fastparquet")

# Check the data type of the columns of the DataFrames
print(sales_data.____)

# Print the shape of the DataFrame, as well as the head
print(sales_data.____)
print(sales_data.____())
編輯並執行程式碼