การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น
Davina Moossazadeh
Data Scientist
GX components - คลาส Python ที่แทนข้อมูลและ entity การตรวจสอบข้อมูล
Data Sources:
Expectation Suites:
Validation Definitions:
Checkpoints:
context.data_sources
$$
context.suites
$$
context.validation_definitions
$$
context.checkpoints
Expectation Suite:
suite = context.suites.add(suite)
Validation Definition:
validation_definition = context.validation_definitions.add(validation_definition)
Checkpoint:
checkpoint = context.checkpoints.add(
checkpoint=checkpoint
)
data_source = context.data_sources.add_<TYPE_NAME>()

ใช้ .add_pandas() เพื่อตั้งค่า Data Source สำหรับ pandas DataFrames ได้อย่างง่ายดาย:
data_source = context.data_sources.add_pandas(
name="my_pandas_datasource"
)
ดึง components ด้วย .get() โดยระบุพารามิเตอร์ name:
context.<COMPONENT>s.get(name: str )
data_source = context.data_sources.get(name="my_pandas_datasource" )print(data_source)
id: 46c91f1b-1db9-4351-b5dd-83e038c0f511
name: 'my_pandas_datasource'
type: pandas
Data Sources:
context.data_sources.get(
name="my_pandas_datasource"
)
Expectation Suites:
context.suites.get(
name="my_suite"
)
Validation Definitions:
context.validation_definitions.get(
name="my_validation_definition"
)
Checkpoints:
context.checkpoints.get(
name="my_checkpoint"
)
ใช้ .all() เพื่อแสดงรายการ components ทั้งหมดใน Data Context รวมถึงชื่อและ metadata:
context.<COMPONENT>s.all()
data_sources = context.data_sources.all()print(data_sources)
{
'my_pandas_datasource': PandasDatasource(
type='pandas',
name='my_pandas_datasource',
id=UUID('c22b16f7-6945-400e-932f-026cbd63b112'),
assets=[]
)
}
Data Sources:
context.data_sources.all()
Expectation Suites:
context.suites.all()
Validation Definitions:
context.validation_definitions.all()
Checkpoints:
context.checkpoints.all()
ใช้ .delete() เพื่อลบ components โดยระบุชื่อ:
context.<COMPONENT>s.delete(name: str )
context.data_sources.delete( name="my_pandas_datasource" )print(context.data_sources.all())
{}
Data Sources:
context.data_sources.delete(
name="my_pandas_datasource"
)
Expectation Suites:
context.suites.delete(
name="my_suite"
)
Validation Definitions:
context.validation_definitions.delete(
name="my_validation_definition"
)
Checkpoints:
context.checkpoints.delete(
name="my_checkpoint"
)
เพิ่ม component เข้า Data Context:
context.data_sources.add(data_source)
context.suites.add(suite)
context.validation_definitions.add(
validation_definition
)
context.checkpoints.add(checkpoint)
ดึง component:
.get(name: str)
แสดงรายการ components:
.all()
ลบ component:
.delete(name: str)
การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น