Şema Beklentileri

Great Expectations ile Veri Kalitesine Giriş

Davina Moossazadeh

Data Scientist

Biçim ve şema Beklentileri

Expectation - Veriye dair doğrulanabilir bir iddia

  • Sütun Beklentileri
  • Biçim ve şema Beklentileri
    • şema - bir veri kümesinin yapısının planı
1 https://docs.greatexpectations.io/docs/reference/learn/terms/expectation
Great Expectations ile Veri Kalitesine Giriş

Satır sayısı

row_count_expectation = gx.expectations.ExpectTableRowCountToEqual(
    value=118000
)

validation_results = batch.validate(expect=row_count_expectation)
print(validation_results.success)
False
print(validation_results.result)
{'observed_value': 118066}
Great Expectations ile Veri Kalitesine Giriş

Satır sayısı aralığı

Satır sayısı için bir aralık tanımlamak üzere ExpectTableRowCountToBeBetween kullanın:

row_count_expectation = gx.expectations.ExpectTableRowCountToBeBetween(

min_value=117000, max_value=119000 )
validation_results = batch.validate(expect=row_count_expectation)
print(validation_results.success)
True
print(validation_results.result)
{'observed_value': 118066}
Great Expectations ile Veri Kalitesine Giriş

Sütun sayısı

col_count_expectation = gx.expectations.ExpectTableColumnCountToEqual(
    value=15
)
validation_results = batch.validate(expect=col_count_expectation)
print(validation_results.success)
False
print(validation_result.result)
{'observed_value': 18}
Great Expectations ile Veri Kalitesine Giriş

Sütun sayısı aralığı

Sütun sayısı için bir aralık tanımlamak üzere ExpectTableColumnCountToBeBetween kullanın:

col_count_expectation = gx.expectations.ExpectTableColumnCountToBeBetween(
    min_value=14, max_value=18
)
validation_results = batch.validate(expect=col_count_expectation)
print(validation_results.success)
True
print(validation_result.result)
{'observed_value': 18}
Great Expectations ile Veri Kalitesine Giriş

Sütun adı kümeleri

Sütun adlarını bir kümeye göre doğrulamak için ExpectTableColumnsToMatchSet kullanın:

expected_cols = ['clouds_all', 'snow_1h', 'rain_1h', 'wind_speed', 'humidity', 
'pressure', 'temp', 'GHI', 'Energy delta[Wh]', 'Time', 'Time']

col_names_expectation = gx.expectations.ExpectTableColumnsToMatchSet( column_set=expected_cols )
print(col_names_expectation.success, col_names_expectation.result)
True 
{'observed_value': ['Time', 'Energy delta[Wh]', 'GHI', 'temp', 'pressure',
'humidity', 'wind_speed', 'rain_1h', 'snow_1h', 'clouds_all'}
Great Expectations ile Veri Kalitesine Giriş

Tekil sütun adları

Veri setinde belirli bir sütunun olup olmadığını kontrol etmek için ExpectColumnToExist kullanın:

col_name_expectation = gx.expectations.ExpectColumnToExist(column="not_a_column")
validation_result = batch.validate(expect=col_name_expectation)
print(validation_result.success)
False
col_name_expectation = gx.expectations.ExpectColumnToExist(column="GHI")
validation_result = batch.validate(expect=col_name_expectation)
print(validation_result.success)
True
Great Expectations ile Veri Kalitesine Giriş

Hızlı başvuru

Biçim (shape) Beklentileri:

ExpectTableRowCountToEqual(value: int)
ExpectTableRowCountToBeBetween(
    min_value: int, max_value: int
)
ExpectTableColumnCountToEqual(
    value: int
)
ExpectTableColumnCountToBeBetween(
    min_value: int, max_value: int
)

Sütun adı Beklentileri:

ExpectTableColumnsToMatchSet(
    column_set: set
)
ExpectColumnToExist(column: str)
Great Expectations ile Veri Kalitesine Giriş

Hadi pratik yapalım!

Great Expectations ile Veri Kalitesine Giriş

Preparing Video For Download...