Kỳ vọng theo kiểu dữ liệu

Nhập môn Data Quality với Great Expectations

Davina Moossazadeh

Data Scientist

Kỳ vọng số: mức tổng hợp

gx.expectations.ExpectColumnMeanToBeBetween(
    column="mark_price_usd", min_value=20, max_value=25
)

gx.expectations.ExpectColumnMedianToBeBetween( column="mark_price_usd", min_value=20, max_value=25 )
gx.expectations.ExpectColumnStdevToBeBetween( column="mark_price_usd", min_value=15, max_value=20 )
gx.expectations.ExpectColumnSumToBeBetween( column="mark_price_usd", min_value=20000, max_value=21000 )
Nhập môn Data Quality với Great Expectations

Kỳ vọng số: mức hàng

Đặt kỳ vọng mức hàng cho khoảng giá trị:

gx.expectations.ExpectColumnValuesToBeBetween(
    column="star_rating", min_value=0, max_value=5
)

hoặc thứ tự:

gx.expectations.ExpectColumnValuesToBeIncreasing(
    column="price_usd"
)

gx.expectations.ExpectColumnValuesToBeDecreasing( column="price_usd" )
Nhập môn Data Quality với Great Expectations

Kỳ vọng chuỗi

Đặt kỳ vọng cho chuỗi (đều ở mức hàng):

gx.expectations.ExpectColumnValueLengthsToEqual(
    column="sku_id", value=18
)

gx.expectations.ExpectColumnValuesToMatchRegex( column="link", regex="^https://us.shein.com/[\w-]+" )
regex_list = [ "//img.ltwebstatic.com/images3_(spmp)|(pi)/202[0-4]/[0-1][0-9]/.*", "//sheinsz.ltwebstatic.com/she_dist/images/bg-g.*" ]
gx.expectations.ExpectColumnValuesToMatchRegexList( column="hero_image", regex_list=regex_list )
Nhập môn Data Quality với Great Expectations

Kỳ vọng khả năng phân tích chuỗi

Đặt kỳ vọng cho cột chuỗi để bảo đảm có thể phân tích cú pháp

ExpectColumnValuesToBeDateutilParseable() cho ngày:

gx.expectations.ExpectColumnValuesToBeDateutilParseable(
    column="colour"
)

ExpectColumnValuesToBeJsonParseable() cho JSON:

gx.expectations.ExpectColumnValuesToBeJsonParseable(
    column="colour"
)
Nhập môn Data Quality với Great Expectations

Ghi chú nhanh

Kỳ vọng số:

ExpectColumn<METRIC>ToBeBetween(
    column, min_value, max_value
)
# <METRIC> trong {"Mean", "Median", "Stdev", "Sum"}

ExpectColumnValuesToBeBetween(
    column, min_value, max_value
)

ExpectColumnValuesToBeIncreasing(column)

ExpectColumnValuesToBeDecreasing(column)

Kỳ vọng chuỗi:

ExpectColumnValueLengthsToEqual(column, value)

ExpectColumnValuesToMatchRegex(column, regex)

ExpectColumnValuesToMatchRegexList(
    column, regex_list
)

ExpectColumnValuesToBeDateutilParseable(column)

ExpectColumnValuesToBeJsonParseable(column)
Nhập môn Data Quality với Great Expectations

Ayo berlatih!

Nhập môn Data Quality với Great Expectations

Preparing Video For Download...