Polars 데이터프레임 소개

Polars 입문

Liam Brannigan

Data Scientist and Polars Contributor

강사 소개

$$

  • Liam Brannigan, 수석 데이터 과학자
  • ML 및 데이터 엔지니어링 전문가
  • Polars 기여자

강사 프로필 사진.

Polars 입문

표 형식 데이터

shape: (49, 8)
| name        | type    | price | bedrooms | doubles | singles | review | beach |
| ---         | ---     | ---   | ---      | ---     | ---     | ---    | ---   |
| str         | str     | i64   | i64      | i64     | i64     | f64    | bool  |
|-------------|---------|-------|----------|---------|---------|--------|-------|
| Waves       | Cottage | 540   | 4        | 1       | 2       | 8.9    | false |
| Seashells   | Cottage | 540   | 4        | 2       | 2       | 8.7    | true  |
| Lake view   | Cottage | 714   | 3        | 1       | 4       | 9.2    | true  |
| Piran View  | null    | 775   | null     | 1       | 3       | 9.6    | false |
| Palma Villa | Cottage | 1772  | 4        | 1       | 2       | 9.6    | true  |
Polars 입문

눈 위를 걷는 북극곰과 숲속 판다의 나란한 이미지.

  • Polars는 보통 Pandas보다 빠릅니다 → 병렬 계산
  • Polars의 lazy 모드는 쿼리를 최적화합니다
Polars 입문

Apache Arrow와 Rust 로고.

  • Apache Arrow: 메모리에 표 형식 데이터를 저장
  • Rust: 데이터 처리에 빠른 언어
Polars 입문

데이터 로딩을 보여 주는 데이터베이스 개략도.

  • 데이터 로딩 및 확인
Polars 입문

변환을 나타내는 데이터베이스와 기어의 개략도.

  • 데이터 로딩 및 확인
  • 데이터 변환과 최적화
Polars 입문

분석을 나타내는 데이터베이스, 기어, 차트의 개략도.

  • 데이터 로딩 및 확인
  • 데이터 변환과 최적화
  • 데이터 분석
Polars 입문

CSV 읽기

import polars as pl


rentals = pl.read_csv("vacation_rentals.csv")
Polars 입문

데이터프레임의 처음 행

rentals.head(3)

rentals 데이터프레임의 처음 몇 행.

Polars 입문

데이터프레임의 처음 행

rentals.head(3)

모양이 강조된 rentals 데이터프레임.

Polars 입문

데이터프레임의 처음 행

rentals.head(3)

첫 번째 열이 강조된 rentals 데이터프레임.

  • dtype: 열의 데이터 타입
Polars 입문

데이터프레임의 처음 행

rentals.head(3)

rentals 열이 강조된 rentals 데이터프레임.

Polars 입문

데이터프레임의 마지막 행

rentals.tail()
shape: (5, 8)
| name                | type      | price | bedrooms | doubles | singles | review | beach |
| ---                 | ---       | ---   | ---      | ---     | ---     | ---    | ---   |
| str                 | str       | i64   | i64      | i64     | i64     | f64    | bool  |
|---------------------|-----------|-------|----------|---------|---------|--------|-------|
| Hengar Manor House  | Cottage   | 615   | 4        | 1       | 5       | 9.4    | false |
| Tudor Cottage Hayle | Cottage   | 489   | 3        | 2       | 3       | 8.9    | false |
| Tolcarne Apartments | Apartment | 1764  | 3        | 1       | 4       | 9.3    | true  |
| Tolcarne Apartments | Apartment | 1605  | 3        | 1       | 4       | 9.3    | true  |
| Tehidy Holiday Park | Cottage   | 637   | 4        | 2       | 4       | 9.0    | false |
Polars 입문

데이터프레임 메타데이터

rentals.shape
(49, 8)
rentals.columns
['name', 'type', 'price', 'bedrooms', 'doubles', 'singles', 'review', 'beach']
Polars 입문

데이터프레임 스키마

rentals.schema
Schema([('name', String),
        ('type', String),
        ('price', Int64),
        ('bedrooms', Int64),
        ('doubles', Int64),
        ('singles', Int64),
        ('review', Float64),
        ('beach', Boolean)])
Polars 입문

데이터프레임 점검

rentals.glimpse()
Rows: 49
Columns: 8
$ name      <str> 'Waves', 'Seashells', 'Lake view', 'Piran View',...
$ type      <str> 'Cottage', 'Cottage', 'Cottage', None, 'Cottage',...
$ price     <i64> 540, 540, 714, 775, 1772, 934, 1947, 1026, 705, 863
$ bedrooms  <i64> 4, 4, 3, None, 4, 3, 4, 3, 4, 3
$ doubles   <i64> 1, 2, 1, 1, 1, 1, 1, 1, 1, 1
$ singles   <i64> 2, 2, 4, 3, 2, 4, 2, 4, 2, 2
$ review    <f64> 8.9, 8.7, 9.2, 9.6, 9.6, 8.6, 9.6, 8.6, 9.7, 9.1
$ beach    <bool> False, True, True, False, True, True, True, True, True, True
Polars 입문

Vamos praticar!

Polars 입문

Preparing Video For Download...