데이터 파이프라인의 엔드 투 엔드 테스트
이 연습 문제에서는 앞서 사용한 것과 동일한 데이터 파이프라인을 다룹니다. 이 파이프라인은 세금을 추출(Extract), 변환(Transform), 적재(Load)합니다. 파이프라인을 엔드 투 엔드로 테스트하여, parquet 파일에 변환된 데이터가 중복 저장되지 않으면서도 여러 번 실행할 수 있도록 확인해 보세요.
pandas는 pd로 로드되어 있으며, extract(), transform(), load() 함수는 이미 정의되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 ETL과 ELT
연습 안내
for루프를 사용해 ETL 파이프라인을 세 번 실행하세요.- 파이프라인을 한 번 실행할 때마다
clean_tax_data의 shape를 출력하세요. "clean_tax_data.parquet"파일에 저장된 DataFrame을 읽어to_validate변수에 담으세요.- 각 파이프라인 실행 시 데이터가 중복되지 않았는지 확인하기 위해,
to_validateDataFrame의 shape를clean_tax_rate의 shape와 비교하여 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Trigger the data pipeline to run three times
____ attempt in range(0, ____):
print(f"Attempt: {attempt}")
raw_tax_data = extract("raw_tax_data.csv")
clean_tax_data = transform(raw_tax_data)
load(clean_tax_data, "clean_tax_data.parquet")
# Print the shape of the cleaned_tax_data DataFrame
print(f"Shape of clean_tax_data: {clean_tax_data.____}")
# Read in the loaded data, check the shape
to_validate = pd.____("clean_tax_data.parquet")
print(f"Final shape of cleaned data: {to_validate.____}")