Beklenti Takımlarını Güncelleme

Great Expectations ile Veri Kalitesine Giriş

Davina Moossazadeh

Data Scientist

Beklentileri Ekleme

expectation = gx.expectations.ExpectTableColumnCountToEqual(
    value=10
)
suite = gx.ExpectationSuite(
    name="my_suite"
)
# Beklentiyi Takıma ekle
suite.add_expectation(
    expectation=expectation
)
Great Expectations ile Veri Kalitesine Giriş

Birden Çok Beklenti Takımı

# Başka bir Beklenti Takımı oluştur
another_suite = gx.ExpectationSuite(name="my_other_suite")
# Aynı Beklentiyi yeni Takıma ekle
another_suite.add_expectation(expectation=expectation)

Beklentiler aynı anda birden fazla Takıma ait olamaz:

RuntimeError: Cannot add Expectation because it already belongs to an 
ExpectationSuite. If you want to update an existing Expectation, please call 
Expectation.save(). If you are copying this Expectation to a new ExpectationSuite, 
please copy it first (the core expectations and some others support 
copy(expectation)) and set `Expectation.id = None`.
Great Expectations ile Veri Kalitesine Giriş

Beklentileri Kopyalama

If you are copying this Expectation to a new ExpectationSuite, please copy it first 
(the core expectations and some others support copy(expectation)) and set 
`Expectation.id = None`.

Beklentiyi kopyalayın, .id değerini None yapın ve hatasız şekilde yeni Takıma ekleyin:

expectation_copy = expectation.copy()

expectation_copy.id = None
another_suite.add_expectation(
    expectation=expectation_copy
)
Great Expectations ile Veri Kalitesine Giriş

Beklentileri Kontrol Etme

print(
    expectation_copy in another_suite.expectations
)
True
Great Expectations ile Veri Kalitesine Giriş

Beklentileri Silme

Ekle

.add_expectation()

suite.add_expectation(
    expectation=expectation
)

Sil

.delete_expectation()

suite.delete_expectation(
    expectation=expectation
)
Great Expectations ile Veri Kalitesine Giriş

Beklentileri Ayarlama

.value özniteliğini güncelleyin ve değişiklikleri kaydedin:

expectation = gx.expectations.ExpectTableColumnCountToEqual(
    value=10
)

expectation.value = 11
expectation.save()

Beklentinin bir Takıma ait olduğundan emin olun, aksi halde:

RuntimeError: Expectation must be added to ExpectationSuite before it can be saved.
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Güncelleme

suite = gx.ExpectationSuite(name="my_suite") 
validation_definition = gx.ValidationDefinition(
    data=batch_definition, suite=suite, name="my_validation_definition"
)
# Beklentiyi tanımla
col_name_expectation = gx.expectations.ExpectColumnToExist(column="GHI")

# Beklentiyi Takıma ekle suite.add_expectation(expectation=col_name_expectation)
# Takım ile ilişkili Doğrulama Tanımını çalıştır validation_results = validation_definition.run()
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Kaydetme

Hataları önlemek için Doğrulama Tanımını çalıştırmadan önce Takımdaki değişiklikleri kaydedin:

validation_results = validation_definition.run()
ResourceFreshnessAggregateError: ExpectationSuite 'my_suite' has changed since it 
has last been saved. Please update with `<SUITE_OBJECT>.save()`, then try your 
action again.
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Kaydetme

Takımı kaydetmek ve Doğrulama Tanımını hatasız çalıştırmak için .save() yöntemini kullanın:

suite.save()

validation_results = validation_definition.run()
print(validation_results.success)
False
Great Expectations ile Veri Kalitesine Giriş

Kısa rehber

Beklentiyi kopyalayın:

expectation_copy = expectation.copy()
expectation_copy.id = None

Beklentinin Takımda olup olmadığını kontrol edin:

expectation in suite.expectations

Beklentiyi silin:

suite.delete_expectation(expectation)

Beklenti değerini güncelleyin:

expectation.value = new_value

Beklentideki değişiklikleri kaydedin:

expectation.save()

Beklenti Takımındaki değişiklikleri kaydedin:

suite.save()
Great Expectations ile Veri Kalitesine Giriş

Haydi pratik yapalım!

Great Expectations ile Veri Kalitesine Giriş

Preparing Video For Download...