시작하기무료로 시작하기

스키마 테스트하기

팀에서 expected DataFrame의 값을 수정했지만, Polars가 total_checkouts를 64비트로 추론한 반면 파이프라인은 32비트를 생성합니다. 두 스키마의 불일치를 확인할 수 있도록 미리 출력해 두었습니다. expected의 데이터 타입을 수정한 후, 두 스키마가 일치하는지 검증하세요.

actual, expected, assert_schema_equal은 미리 로드되어 있습니다.

이 연습은 강의의 일부입니다

Polars로 데이터 파이프라인 확장 및 최적화하기

강의 보기

연습 안내

  • expectedtotal_checkouts 열을 pl.Int32로 형변환하세요.
  • actualexpected의 스키마가 동일한지 검증하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Match the dtype the pipeline produces
expected = expected.with_columns(
    pl.col("total_checkouts").cast(pl.____)
)

# Schema-level assertion
____(actual.schema, expected.schema)
print("Schema assertion passed.")
print(actual.schema)
코드 편집 및 실행