Citirea datelor în loturi

Introducere în calitatea datelor cu Great Expectations

Davina Moossazadeh

Data Scientist

Date meteo Kaggle

Un DataFrame pandas cu datele meteo Kaggle, cu coloanele: "Location", "Date_Time", "Temperature_C", "Humidity_pct", "Precipitation_mm" și "Wind_Speed_kmh". DataFrame-ul are 87.118 rânduri.

Introducere în calitatea datelor cu Great Expectations

Batch Definitions

Batch Definition - O configurație pentru modul în care un Data Asset este împărțit pentru testare

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/
Introducere în calitatea datelor cu Great Expectations

Loturi (Batches)

Batch - Un grup de înregistrări pe care se pot rula validări

batch = batch_definition.get_batch(

batch_parameters={"dataframe": dataframe} )
Introducere în calitatea datelor cu Great Expectations

Loturi (Batches)

data_source_other.jpg

data_source_pandas.jpg

Introducere în calitatea datelor cu Great Expectations

Obiectul Batch

Se poate folosi .head() ca în pandas:

print(batch.head())

Captură de ecran 2024-07-16 la 11.49.00.png

1 Table adapted from https://www.kaggle.com/datasets/prasad22/weather-data
Introducere în calitatea datelor cu Great Expectations

Obiectul Batch

print(batch.head(fetch_all=True))

Captură de ecran 2024-07-22 la 14.02.00.png

Introducere în calitatea datelor cu Great Expectations

Obiectul Batch

.columns() afișează toate coloanele DataFrame (notați ())

print(batch.columns())
['Location',
 'Date_Time',
 'Temperature_C',
 'Humidity_pct',
 'Precipitation_mm',
 'Wind_Speed_kmh']
Introducere în calitatea datelor cu Great Expectations

Fișă de referință

Creați o Batch Definition din Data Asset:

batch_definition = data_asset. \
add_batch_definition_whole_dataframe(
  name: str
)

Creați un Batch din Batch Definition:

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

Obțineți rândurile DataFrame din Batch:

batch.head(fetch_all: bool)  

Obțineți lista coloanelor DataFrame din Batch:

batch.columns()
Introducere în calitatea datelor cu Great Expectations

Să exersăm!

Introducere în calitatea datelor cu Great Expectations

Preparing Video For Download...