Thiết lập Expectations ở mức tổng hợp
Đến lúc luyện viết một số Expectations theo cột ở mức tổng hợp. Expectation Suite và Batch đã được gán lần lượt vào biến suite và batch, và đã nạp sẵn bộ dữ liệu Shein Footwear. Great Expectations và pandas lần lượt có sẵn dưới tên gx và pd.
Bài tập này là một phần của khóa học
Nhập môn Data Quality với Great Expectations
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
# "colour" should be in the set "Khaki", "Purple", or "Grey"
colour_expectation = gx.expectations.ExpectColumnDistinctValuesToBeInSet(
____="colour", value_set={"Khaki", "Purple", "Grey"}
)
# "seller_name" should have 7 to 10 distinct values
seller_expectation = gx.expectations.ExpectColumnUniqueValueCountToBeBetween(
column="seller_name", ____=7, ____=10
)
# "link" should have all unique values
link_expectation = gx.expectations.____(
column="link"
)
# "review_count" should have a most common value in the set "0" or "100+"
review_count_expectation = gx.expectations.ExpectColumnMostCommonValueToBeInSet(
column=____, value_set=____
)