Bir Beklenti Takımı Oluşturma

Great Expectations ile Veri Kalitesine Giriş

Davina Moossazadeh

Data Scientist

Beklenti Takımları

Expectation - Veri hakkında doğrulanabilir bir ifade

Expectation Suite - Aynı veri kümesini tanımlayan Beklentiler grubu

1, 2 ve 3 numaralı üç Beklenti içeren bir Beklenti Takımı.

1 https://docs.greatexpectations.io/docs/core/define_expectations/organize_expectation_suites/
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımı Oluşturma

ExpectationSuite sınıfı ile "my_suite" adlı bir Beklenti Takımı oluşturun:

suite = gx.ExpectationSuite(

name="my_suite" )
1 https://docs.greatexpectations.io/docs/core/define_expectations/organize_expectation_suites/
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımı Oluşturma

print(suite)
{
  "name": "my_suite",
  "id": "a8118858-32e4-4d7d-b548-9cd7d5048958",
  "expectations": [],
  "meta": {
    "great_expectations_version": "1.2.4"
  },
  "notes": null
}
Great Expectations ile Veri Kalitesine Giriş

Beklentiler Ekleme

Bir Takıma Beklenti eklemek için .add_expectation() kullanın (her seferinde bir Beklenti):

expectation = gx.expectations.ExpectTableRowCountToEqual(
    value=118000
)
suite.add_expectation(

expectation=expectation )
Great Expectations ile Veri Kalitesine Giriş

Beklentiler Ekleme

print(suite)
{ "name": "my_suite",
  "id": "a8118858-32e4-4d7d-b548-9cd7d5048958",
  "expectations": [
      {"type": "expect_table_row_count_to_equal",
       "kwargs": {"value": "118000"},
       "meta": {},
       "id": "3f1f21db-2146-417a-876e-43e11b635665"}
  ],
  "meta": {"great_expectations_version": "1.2.4"},
  "notes": null }
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Görüntüleme

print(suite.expectations)

print(suite["expectations"])
[
    ExpectTableRowCountToEqual(
        id='3f1f21db-2146-417a-876e-43e11b635665', 
        meta=None, notes=None, result_format=<ResultFormat.BASIC: 'BASIC'>, 
        description=None, catch_exceptions=False, rendered_content=None, 
        batch_id=None, row_condition=None, condition_parser=None, 
        value=118000
    ),
]
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Görüntüleme

print(suite.name)
print(suite["name"])
"my_suite"
print(suite.id)
print(suite["id"])
"a8118858-32e4-4d7d-b548-9cd7d5048958"
print(suite.meta)
print(suite["meta"])
{"great_expectations_version": "1.2.4"}
print(suite.notes)
print(suite["notes"])
None
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Doğrulama

expect parametresini Takım olarak ayarlayıp batch.validate() ile bir Beklenti Takımını doğrulayın:

validation_results = batch.validate(

expect=suite )
print(validation_results)
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Doğrulama

{ "success": false,
  "results": [{
      "success": false,
      "expectation_config": {
          "type": "expect_table_row_count_to_equal", "kwargs": {"batch_id": "my_datasource-my_dataframe_asset", "value": 118000}, "meta": {}, "rendered_content": [{"name": "atomic.prescriptive.summary", "value": {"schema": {"type": "com.superconductive.rendered.string"}, "template": "Must have exactly $value rows.", "params": {"value": {"schema": {"type": "number"}, "value": 118000}}}, "value_type": "StringValueType"}]
      },
      "result": {"observed_value": 118066},
      "meta": {},
      "exception_info": {"raised_exception": false, "exception_traceback": null, "exception_message": null},
      "rendered_content": [{"name": "atomic.diagnostic.observed_value", "value": {"schema": {"type": "com.superconductive.rendered.string"}, "template": "118066", "params": {}}, "value_type": "StringValueType"}]
  }],
  "suite_name": "my_suite",
  "suite_parameters": {},
  "statistics": {"evaluated_expectations": 1, "successful_expectations": 0, "unsuccessful_expectations": 1, "success_percent": 0.0},
  "meta": {
    "great_expectations_version": "1.2.4",
    "batch_spec": {"batch_data": "PandasDataFrame"},
    "batch_markers": {"ge_load_time": "20241118T192902.403204Z", "pandas_data_fingerprint": "7d6363a614af65df638bdb6c053b44d3"},
    "active_batch_definition": {"datasource_name": "my_datasource", "data_connector_name": "fluent", "data_asset_name": "my_dataframe_asset", "batch_identifiers": {"dataframe": "<DATAFRAME>"}}
  },
  "id": null }
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Takımını Doğrulama

print(validation_results.success)
False
print(validation_results.describe())
Great Expectations ile Veri Kalitesine Giriş

Beklenti Takımı Doğrulama Sonuçları

{ "success": false,
  "statistics": {
    "evaluated_expectations": 1, "successful_expectations": 0,
    "unsuccessful_expectations": 1, "success_percent": 0.0
  },
  "expectations": [{
    "expectation_type": "expect_table_row_count_to_equal",
    "success": false,
    "kwargs": {"batch_id": "my_datasource-my_dataframe_asset", "value": 118000},
    "result": {"observed_value": 118066}},
  ],
  "result_url": null
}
Great Expectations ile Veri Kalitesine Giriş

Kısa rehber

Beklenti Takımı oluşturma:

suite = gx.ExpectationSuite(name: str)

Takıma Beklenti ekleme:

suite.add_expectation(expectation)

Takımın Beklentilerine erişim:

suite.expectations

Beklenti Takımını doğrulama:

validation_results = batch.validate(
    expect=suite
)

Doğrulama sonuçlarını kontrol etme:

validation_results.success
validation_results.describe()
Great Expectations ile Veri Kalitesine Giriş

Ayo berlatih!

Great Expectations ile Veri Kalitesine Giriş

Preparing Video For Download...