使用 assert 驗證資料管線
若要為資料管線撰寫單元測試,你需要熟悉 assert 關鍵字與 isinstance() 函式。這題會讓你練習使用這兩個工具來驗證資料管線的元件。
本題已提供 extract() 與 transform() 函式,以及已匯入並命名為 pd 的 pandas。extract() 與 transform() 都會回傳一個 DataFrame。加油!
本練習屬於課程
使用 Python 的 ETL 與 ELT
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
raw_tax_data = extract("raw_tax_data.csv")
clean_tax_data = transform(raw_tax_data)
# Validate the number of columns in the DataFrame
____ len(clean_tax_data.columns) == ____