อ่านข้อมูลแบบ Batch

การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

Davina Moossazadeh

Data Scientist

Kaggle Weather Data

pandas DataFrame ที่มีข้อมูล Kaggle Weather Data ประกอบด้วยคอลัมน์ "Location", "Date_Time", "Temperature_C", "Humidity_pct", "Precipitation_mm" และ "Wind_Speed_kmh" มีทั้งหมด 87,118 แถว

การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

Batch Definitions

Batch Definition — การกำหนดค่าสำหรับแบ่ง Data Asset เพื่อการทดสอบ

batch_definition = data_asset.add_batch_definition_whole_dataframe(

name="my_batch_definition" )
print(batch_definition)
id='69e2a81d-1c28-4d1a-b66e-52cdc1198266' 
name='my_batch_definition' 
partitioner=None
1 https://docs.greatexpectations.io/docs/core/connect_to_data/dataframes/
การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

Batches

Batch — กลุ่มระเบียนที่ใช้รัน Validation

batch = batch_definition.get_batch(

batch_parameters={"dataframe": dataframe} )
การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

Batches

data_source_other.jpg

data_source_pandas.jpg

การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

ออบเจกต์ Batch

ใช้ .head() ได้เช่นเดียวกับ pandas:

print(batch.head())

Screenshot 2024-07-16 at 11.49.00.png

1 ตารางดัดแปลงจาก https://www.kaggle.com/datasets/prasad22/weather-data
การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

ออบเจกต์ Batch

print(batch.head(fetch_all=True))

Screenshot 2024-07-22 at 14.02.00.png

การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

ออบเจกต์ Batch

.columns() แสดงคอลัมน์ทั้งหมดของ DataFrame (สังเกต ())

print(batch.columns())
['Location',
 'Date_Time',
 'Temperature_C',
 'Humidity_pct',
 'Precipitation_mm',
 'Wind_Speed_kmh']
การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

สรุปคำสั่ง

สร้าง Batch Definition จาก Data Asset:

batch_definition = data_asset. \
add_batch_definition_whole_dataframe(
  name: str
)

สร้าง Batch จาก Batch Definition:

batch = batch_definition.get_batch(
  batch_parameters={"dataframe": dataframe}
)

ดึงแถวข้อมูลจาก Batch DataFrame:

batch.head(fetch_all: bool)  

ดึงรายการคอลัมน์จาก Batch DataFrame:

batch.columns()
การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

มาฝึกกันเถอะ!

การตรวจสอบคุณภาพข้อมูลด้วย Great Expectations เบื้องต้น

Preparing Video For Download...