본문 바로가기
C.W.K.
Stream
Lesson 03 of 08 · published

Pandas, Arrow, 뷰어로 탐색

~22 min · datasets, explore

Level 0스카우트
0 XP0/50 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

같은 테이블을 필요한 도구로 들여다봐

Dataset는 Arrow 기반이라 내용을 확인하려고 매번 pandas로 바꿀 필요가 없어. pandas 연산이 필요하면 ds.to_pandas()를 쓰고, Arrow 테이블 자체가 필요하면 ds.with_format('arrow')pa.Table을 받아. 스키마가 허용하면 불필요한 복사도 피할 수 있어.

받기 전에 Hub에서 표본을 확인해

데이터셋 페이지의 Data Studio는 자동 변환된 Parquet를 조회해 수천 행을 빠르게 훑게 해 줘. 같은 기능을 Dataset Viewer API로도 호출할 수 있어. rows 끝점에 dataset·config·split·offset·length를 넘기면 전체 자료를 내려받지 않고 표본과 열 구조를 검사할 수 있어.

Code

Pandas + Arrow 변환·python
from datasets import load_dataset

ds = load_dataset("stanfordnlp/imdb", split="train")

# Pandas — ad-hoc 분석에 편함
df = ds.to_pandas()
print(df.label.value_counts())
print(df.text.str.len().describe())

# Arrow — 다운스트림 zero-copy path 위해
arrow_tbl = ds.with_format("arrow").select(range(10))[:]
print(type(arrow_tbl))  # pyarrow.lib.Table
데이터셋 뷰어 API 직접 치기·bash
curl -s "https://datasets-server.huggingface.co/rows?dataset=stanfordnlp%2Fimdb&config=plain_text&split=train&offset=0&length=2" | python -m json.tool | head -40

External links

Exercise

도메인 다른 데이터셋 셋 (text, audio, image) 골라. 각각 dataset viewer API 로 처음 50 행 hit. JSON 저장. 어떤 필드가 scalar, 어떤 게 파일 URL, 어떤 게 inline binary embed 됐는지 메모.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.