按类型的期望

使用 Great Expectations 的数据质量入门

Davina Moossazadeh

Data Scientist

数值型期望:聚合级

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 )
使用 Great Expectations 的数据质量入门

数值型期望:行级

为行级设置取值范围期望:

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

或有序性:

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

gx.expectations.ExpectColumnValuesToBeDecreasing( column="price_usd" )
使用 Great Expectations 的数据质量入门

字符串期望

设置字符串期望(均为行级):

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 )
使用 Great Expectations 的数据质量入门

字符串可解析性期望

为字符串列设置可解析性期望

日期用 ExpectColumnValuesToBeDateutilParseable()

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

JSON 用 ExpectColumnValuesToBeJsonParseable()

gx.expectations.ExpectColumnValuesToBeJsonParseable(
    column="colour"
)
使用 Great Expectations 的数据质量入门

速查表

数值型期望:

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

ExpectColumnValuesToBeBetween(
    column, min_value, max_value
)

ExpectColumnValuesToBeIncreasing(column)

ExpectColumnValuesToBeDecreasing(column)

字符串期望:

ExpectColumnValueLengthsToEqual(column, value)

ExpectColumnValuesToMatchRegex(column, regex)

ExpectColumnValuesToMatchRegexList(
    column, regex_list
)

ExpectColumnValuesToBeDateutilParseable(column)

ExpectColumnValuesToBeJsonParseable(column)
使用 Great Expectations 的数据质量入门

开始练习!

使用 Great Expectations 的数据质量入门

Preparing Video For Download...