데이터 파이프라인의 모니터링과 알림
이제 모든 것을 하나로 이어 볼 시간이에요! 눈치채셨겠지만, try-except로 오류를 처리하는 방법과 로깅은 함께 사용하면 특히 효과적이에요. 이 두 가지는 파이프라인을 탄탄하고 투명하게 만드는 데 필수이며, 더 고급 모니터링과 알림 솔루션의 기반이 됩니다.
pandas는 pd로 임포트되어 있고, logging 모듈도 미리 로드되어 설정해 두었어요. raw_sales_data DataFrame은 추출이 완료되어, 이제 변환할 준비가 되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 ETL과 ELT
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
def transform(raw_data):
return raw_data.loc[raw_data["Total Price"] > 1000, :]
try:
# Attempt to transform DataFrame, log an info-level message
clean_sales_data = transform(raw_sales_data)
logging.____("Successfully filtered DataFrame by 'Total Price'")
except Exception:
# Log a warning-level message
____.____("Cannot filter DataFrame by 'Total Price'")