Expectation Suites अपडेट करें

Great Expectations के साथ Data Quality परिचय

Davina Moossazadeh

Data Scientist

Expectations जोड़ना

expectation = gx.expectations.ExpectTableColumnCountToEqual(
    value=10
)
suite = gx.ExpectationSuite(
    name="my_suite"
)
# Add Expectation to Suite
suite.add_expectation(
    expectation=expectation
)
Great Expectations के साथ Data Quality परिचय

Multiple Expectation Suites

# Create another Expectation Suite
another_suite = gx.ExpectationSuite(name="my_other_suite")
# Add the same Expectation to the new Suite
another_suite.add_expectation(expectation=expectation)

Expectations एक साथ कई Suites में नहीं हो सकते:

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 के साथ Data Quality परिचय

Expectations कॉपी करना

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`.

Expectation को कॉपी करें, उसकी .id को None करें, और बिना त्रुटि नए Suite में जोड़ें:

expectation_copy = expectation.copy()

expectation_copy.id = None
another_suite.add_expectation(
    expectation=expectation_copy
)
Great Expectations के साथ Data Quality परिचय

Expectations जाँचना

print(
    expectation_copy in another_suite.expectations
)
True
Great Expectations के साथ Data Quality परिचय

Expectations हटाना

Add

.add_expectation()

suite.add_expectation(
    expectation=expectation
)

Delete

.delete_expectation()

suite.delete_expectation(
    expectation=expectation
)
Great Expectations के साथ Data Quality परिचय

Expectations समायोजित करना

.value एट्रिब्यूट अपडेट करें और बदलाव सेव करें:

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

expectation.value = 11
expectation.save()

सुनिश्चित करें कि Expectation किसी Suite का हिस्सा हो, वरना:

RuntimeError: Expectation must be added to ExpectationSuite before it can be saved.
Great Expectations के साथ Data Quality परिचय

Expectation Suite अपडेट करना

suite = gx.ExpectationSuite(name="my_suite") 
validation_definition = gx.ValidationDefinition(
    data=batch_definition, suite=suite, name="my_validation_definition"
)
# Define Expectation
col_name_expectation = gx.expectations.ExpectColumnToExist(column="GHI")

# Add Expectation to Suite suite.add_expectation(expectation=col_name_expectation)
# Run Validation Definition associated with the Suite validation_results = validation_definition.run()
Great Expectations के साथ Data Quality परिचय

Expectation Suite सेव करना

Validation Definition चलाने से पहले Suite को सेव करें ताकि त्रुटि न आए:

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 के साथ Data Quality परिचय

Expectation Suite सेव करना

.save() मेथड से Suite सेव करें और Validation Definition बिना त्रुटि चलाएँ:

suite.save()

validation_results = validation_definition.run()
print(validation_results.success)
False
Great Expectations के साथ Data Quality परिचय

Cheat sheet

Expectation कॉपी करें:

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

जाँचें कि Expectation Suite में है या नहीं:

expectation in suite.expectations

Expectation हटाएँ:

suite.delete_expectation(expectation)

Expectation का value अपडेट करें:

expectation.value = new_value

Expectation में बदलाव सेव करें:

expectation.save()

Expectation Suite में बदलाव सेव करें:

suite.save()
Great Expectations के साथ Data Quality परिचय

अभ्यास करते हैं!

Great Expectations के साथ Data Quality परिचय

Preparing Video For Download...