Great Expectations ile Veri Kalitesine Giriş
Davina Moossazadeh
Data Scientist
Koşullu Beklentiler - Verinin bir alt kümesi için Beklentiler
Neden? Çünkü bazı değişkenler diğerlerinin değerlerine bağlıdır
Örnek:
review_count değeri 0 olan tüm satırlarda star_rating sütununun 0 olmasını bekleyen bir BeklentiVarlık Beklentileri iki ek argümanla Koşullu Beklentilere dönüştürülebilir:
row_conditioncondition_parserrow_condition sözdizimini tanımlayan dizeKoşullu Beklentileri pandas ile kullanırken bu argüman "pandas" olarak ayarlanmalıdır
expectation = gx.Expect...(
**kwargs,
condition_parser="pandas",
row_condition=...
)
df["foo"] == 'Two Two'
df["foo"].notNull()
df["foo"] <= datetime.date(2023, 3, 13)
(df["foo"] < 5) & (df["foo"] >= 3.14)
df["foo"].str.startswith("bar")
row_condition'foo == "Two Two"'
'foo.notNull()'
'foo <= datetime.date(2023, 3, 13)'
'(foo > 5) & (foo <= 3.14)'
'foo > 5 and foo <= 3.14'
'foo.str.startswith("bar")'
İçeride tek tırnak kullanmayın
row_condition="foo=='Two Two'" row_condition='foo=="Two Two"' 
İçeride satır sonu kullanmayın
row_condition="""
foo=="Two Two"
"""
row_condition='foo=="Two Two"' 
expectation = gx.expectations.\
ExpectColumnValuesToBeBetween(
column="price_usd",
max_value=10,
)
validation_results = batch.validate(
expect=expectation
)
print(validation_results.success)
False
expectation = gx.expectations.\
ExpectColumnValuesToBeBetween(
column="price_usd",
max_value=10,
condition_parser='pandas',
row_condition='mark_price_usd < 10',
)
validation_results = batch.validate(
expect=expectation
)
print(validation_results.success)
True
Great Expectations ile Veri Kalitesine Giriş