great-expectations
Great Expectationsは、データ品質をテスト・検証するためのPythonフレームワークで、期待値定義、検証スイート作成、データドキュメント構築、データパイプライン統合による自動品質チェックを実現するSkill。
📜 元の英語説明(参考)
Great Expectations is a Python framework for data quality testing and validation. Learn to define expectations, create validation suites, build data docs, and integrate with data pipelines for automated quality checks.
🇯🇵 日本人クリエイター向け解説
Great Expectationsは、データ品質をテスト・検証するためのPythonフレームワークで、期待値定義、検証スイート作成、データドキュメント構築、データパイプライン統合による自動品質チェックを実現するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o great-expectations.zip https://jpskill.com/download/14961.zip && unzip -o great-expectations.zip && rm great-expectations.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14961.zip -OutFile "$d\great-expectations.zip"; Expand-Archive "$d\great-expectations.zip" -DestinationPath $d -Force; ri "$d\great-expectations.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
great-expectations.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
great-expectationsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Great Expectations
Great Expectations (GX) を使用すると、データ品質テストを定義、実行、およびドキュメント化できます。データに関する期待値(「このカラムは決して null になるべきではない」)を表現し、実際のデータに対して検証し、ドキュメントを自動的に生成します。
インストール
# Great Expectations をインストール
pip install great_expectations
# プロジェクトを初期化
great_expectations init
# great_expectations/ ディレクトリを構成とともに作成
プロジェクト構造
great_expectations/
├── great_expectations.yml # メイン設定
├── expectations/ # Expectation suite (JSON)
├── checkpoints/ # 検証チェックポイント
├── plugins/ # カスタム expectation
└── uncommitted/
└── data_docs/ # 生成されたドキュメント
データソースの接続
# setup_datasource.py: PostgreSQL データソースを構成
import great_expectations as gx
context = gx.get_context()
# PostgreSQL データソースを追加
datasource = context.sources.add_postgres(
name="my_postgres",
connection_string="postgresql://user:pass@localhost:5432/analytics",
)
# データアセット(テーブル)を追加
asset = datasource.add_table_asset(
name="orders",
table_name="orders",
)
# または、CSV ファイル用の pandas データソースを追加
pandas_ds = context.sources.add_pandas("local_files")
csv_asset = pandas_ds.add_csv_asset(
name="daily_report",
filepath_or_buffer="data/daily_report.csv",
)
Expectation の定義
# create_expectations.py: orders テーブルの expectation suite を構築
import great_expectations as gx
context = gx.get_context()
# データのバッチを取得
datasource = context.get_datasource("my_postgres")
asset = datasource.get_asset("orders")
batch_request = asset.build_batch_request()
# expectation suite を作成
suite = context.add_expectation_suite("orders_quality_checks")
# validator を取得
validator = context.get_validator(
batch_request=batch_request,
expectation_suite_name="orders_quality_checks",
)
# expectation を追加
validator.expect_column_to_exist("id")
validator.expect_column_to_exist("user_id")
validator.expect_column_to_exist("amount")
validator.expect_column_to_exist("status")
validator.expect_column_values_to_not_be_null("id")
validator.expect_column_values_to_not_be_null("user_id")
validator.expect_column_values_to_not_be_null("amount")
validator.expect_column_values_to_be_unique("id")
validator.expect_column_values_to_be_between(
"amount", min_value=0, max_value=100000,
)
validator.expect_column_values_to_be_in_set(
"status", ["pending", "completed", "cancelled", "refunded"],
)
validator.expect_column_pair_values_a_to_be_greater_than_b(
"updated_at", "created_at", or_equal=True,
)
# テーブルレベルの expectation
validator.expect_table_row_count_to_be_between(min_value=1, max_value=10_000_000)
# suite を保存
validator.save_expectation_suite(discard_failed_expectations=False)
検証の実行
# validate.py: チェックポイントを実行してデータを検証
import great_expectations as gx
context = gx.get_context()
# チェックポイントを作成
checkpoint = context.add_or_update_checkpoint(
name="orders_checkpoint",
validations=[
{
"batch_request": {
"datasource_name": "my_postgres",
"data_asset_name": "orders",
},
"expectation_suite_name": "orders_quality_checks",
},
],
action_list=[
{"name": "store_validation_result", "action": {"class_name": "StoreValidationResultAction"}},
{"name": "update_data_docs", "action": {"class_name": "UpdateDataDocsAction"}},
],
)
# チェックポイントを実行
result = checkpoint.run()
if not result.success:
print("❌ Validation failed!")
for validation in result.run_results.values():
for r in validation["validation_result"]["results"]:
if not r["success"]:
print(f" FAILED: {r['expectation_config']['expectation_type']}")
print(f" {r['result']}")
else:
print("✅ All expectations passed!")
パイプライン統合
# pipeline_check.py: ETL パイプライン(例:Airflow または Prefect)で GX を使用
import great_expectations as gx
import pandas as pd
def validate_dataframe(df: pd.DataFrame, suite_name: str) -> bool:
"""expectation suite に対して pandas DataFrame を検証します。"""
context = gx.get_context()
datasource = context.sources.add_or_update_pandas("runtime")
asset = datasource.add_dataframe_asset("runtime_df")
batch_request = asset.build_batch_request(dataframe=df)
checkpoint = context.add_or_update_checkpoint(
name="runtime_check",
validations=[{
"batch_request": batch_request,
"expectation_suite_name": suite_name,
}],
)
result = checkpoint.run()
return result.success
# パイプラインでの使用
df = pd.read_csv("data/incoming.csv")
if not validate_dataframe(df, "orders_quality_checks"):
raise ValueError("Data quality check failed — aborting pipeline")
Data Docs
# docs.sh: データドキュメントを生成して提供
# Data Docs をビルド
great_expectations docs build
# ローカルで提供
great_expectations docs serve
# ブラウザが http://localhost:8765 で開きます
# Data Docs には以下が含まれます。
# - 説明付きのすべての expectation suite
# - 合格/不合格の詳細を含む検証結果
# - データプロファイリング統計
一般的な Expectation のリファレンス
カラムレベル:
expect_column_to_exist
expect_column_values_to_not_be_null
expect_column_values_to_be_unique
expect_column_values_to_be_in_set
expect_column_values_to_be_between
expect_column_values_to_match_regex
expect_column_mean_to_be_between
expect_column_max_to_be_between
テーブルレベル:
expect_table_row_count_to_be_between
expect_table_row_count_to_equal
expect_table_columns_to_match_ordered_list
複数カラム:
expect_column_pair_values_a_to_be_greater_than_b
expect_compound_columns_to_be_unique 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Great Expectations
Great Expectations (GX) lets you define, run, and document data quality tests. Express expectations about your data ("this column should never be null"), validate against real data, and generate documentation automatically.
Installation
# Install Great Expectations
pip install great_expectations
# Initialize a project
great_expectations init
# Creates great_expectations/ directory with config
Project Structure
great_expectations/
├── great_expectations.yml # Main config
├── expectations/ # Expectation suites (JSON)
├── checkpoints/ # Validation checkpoints
├── plugins/ # Custom expectations
└── uncommitted/
└── data_docs/ # Generated documentation
Connect a Data Source
# setup_datasource.py: Configure a PostgreSQL data source
import great_expectations as gx
context = gx.get_context()
# Add a PostgreSQL datasource
datasource = context.sources.add_postgres(
name="my_postgres",
connection_string="postgresql://user:pass@localhost:5432/analytics",
)
# Add a data asset (table)
asset = datasource.add_table_asset(
name="orders",
table_name="orders",
)
# Or add a pandas datasource for CSV files
pandas_ds = context.sources.add_pandas("local_files")
csv_asset = pandas_ds.add_csv_asset(
name="daily_report",
filepath_or_buffer="data/daily_report.csv",
)
Define Expectations
# create_expectations.py: Build an expectation suite for the orders table
import great_expectations as gx
context = gx.get_context()
# Get a batch of data
datasource = context.get_datasource("my_postgres")
asset = datasource.get_asset("orders")
batch_request = asset.build_batch_request()
# Create an expectation suite
suite = context.add_expectation_suite("orders_quality_checks")
# Get a validator
validator = context.get_validator(
batch_request=batch_request,
expectation_suite_name="orders_quality_checks",
)
# Add expectations
validator.expect_column_to_exist("id")
validator.expect_column_to_exist("user_id")
validator.expect_column_to_exist("amount")
validator.expect_column_to_exist("status")
validator.expect_column_values_to_not_be_null("id")
validator.expect_column_values_to_not_be_null("user_id")
validator.expect_column_values_to_not_be_null("amount")
validator.expect_column_values_to_be_unique("id")
validator.expect_column_values_to_be_between(
"amount", min_value=0, max_value=100000,
)
validator.expect_column_values_to_be_in_set(
"status", ["pending", "completed", "cancelled", "refunded"],
)
validator.expect_column_pair_values_a_to_be_greater_than_b(
"updated_at", "created_at", or_equal=True,
)
# Table-level expectations
validator.expect_table_row_count_to_be_between(min_value=1, max_value=10_000_000)
# Save the suite
validator.save_expectation_suite(discard_failed_expectations=False)
Run Validations
# validate.py: Run a checkpoint to validate data
import great_expectations as gx
context = gx.get_context()
# Create a checkpoint
checkpoint = context.add_or_update_checkpoint(
name="orders_checkpoint",
validations=[
{
"batch_request": {
"datasource_name": "my_postgres",
"data_asset_name": "orders",
},
"expectation_suite_name": "orders_quality_checks",
},
],
action_list=[
{"name": "store_validation_result", "action": {"class_name": "StoreValidationResultAction"}},
{"name": "update_data_docs", "action": {"class_name": "UpdateDataDocsAction"}},
],
)
# Run the checkpoint
result = checkpoint.run()
if not result.success:
print("❌ Validation failed!")
for validation in result.run_results.values():
for r in validation["validation_result"]["results"]:
if not r["success"]:
print(f" FAILED: {r['expectation_config']['expectation_type']}")
print(f" {r['result']}")
else:
print("✅ All expectations passed!")
Pipeline Integration
# pipeline_check.py: Use GX in an ETL pipeline (e.g., with Airflow or Prefect)
import great_expectations as gx
import pandas as pd
def validate_dataframe(df: pd.DataFrame, suite_name: str) -> bool:
"""Validate a pandas DataFrame against an expectation suite."""
context = gx.get_context()
datasource = context.sources.add_or_update_pandas("runtime")
asset = datasource.add_dataframe_asset("runtime_df")
batch_request = asset.build_batch_request(dataframe=df)
checkpoint = context.add_or_update_checkpoint(
name="runtime_check",
validations=[{
"batch_request": batch_request,
"expectation_suite_name": suite_name,
}],
)
result = checkpoint.run()
return result.success
# Usage in pipeline
df = pd.read_csv("data/incoming.csv")
if not validate_dataframe(df, "orders_quality_checks"):
raise ValueError("Data quality check failed — aborting pipeline")
Data Docs
# docs.sh: Generate and serve data documentation
# Build data docs
great_expectations docs build
# Serve locally
great_expectations docs serve
# Opens browser at http://localhost:8765
# Data docs include:
# - All expectation suites with descriptions
# - Validation results with pass/fail details
# - Data profiling statistics
Common Expectations Reference
Column-level:
expect_column_to_exist
expect_column_values_to_not_be_null
expect_column_values_to_be_unique
expect_column_values_to_be_in_set
expect_column_values_to_be_between
expect_column_values_to_match_regex
expect_column_mean_to_be_between
expect_column_max_to_be_between
Table-level:
expect_table_row_count_to_be_between
expect_table_row_count_to_equal
expect_table_columns_to_match_ordered_list
Multi-column:
expect_column_pair_values_a_to_be_greater_than_b
expect_compound_columns_to_be_unique