mcpField
D
data-profiler

data-profiler

github.com/majesticlabs-devデータ・データベース5067 回インストール7 週間前に更新
リポジトリ

data-profiler について

データエンジニアやアナリスト向けのデータセット調査スキルです。列統計、相関、欠損パターン、品質フラグを分析し、Markdown、JSON、オプションの HTML レポートを作成します。

主な機能

  1. 01データセットの形状とメモリ使用量の分析
  2. 02数値、文字列、日時、カテゴリの分析
  3. 03相関と欠損パターンの分析
  4. 04データ品質問題の自動フラグ付け
  5. 05Markdown、JSON、任意の HTML ダッシュボードでの出力

活用シーン

  1. 01新たに受け取ったデータセットの評価
  2. 02相関の高い列の検出
  3. 03欠損値や重複の疑いの調査
  4. 04レビュー用のプロファイルレポートの作成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill data-profiler

インストール後、Claude Code で/data-profilerを入力して読み込まれたか確認します。

同梱ファイルscripts/profiling.py

詳細

データプロファイラー

対象読者: 新しいデータセットを調査するデータエンジニアやアナリスト。

目的: 統計情報、相関関係、欠損パターンを含む包括的なプロファイルを生成します。

スクリプト

scripts/profiling.py のプロファイリング関数を実行します。

from scripts.profiling import (
    profile_dataframe,
    print_profile_summary,
    profile_correlations,
    profile_missing_patterns
)

使用例

基本的なプロファイリング
import pandas as pd
from scripts.profiling import profile_dataframe, print_profile_summary

df = pd.read_csv('data.csv')
profile = profile_dataframe(df)
print_profile_summary(profile)

出力:

Shape: 10,000 rows x 15 columns
Memory: 1.23 MB

Column Summary:
  id (int64): 10,000 unique, no nulls
  email (object): 9,847 unique, 1.53% null
  revenue (float64): 3,421 unique, no nulls
  created_at (datetime64[ns]): 365 unique, no nulls
相関分析
from scripts.profiling import profile_correlations

corr = profile_correlations(df, threshold=0.7)

if corr['high_correlations']:
    print("Highly correlated columns:")
    for c in corr['high_correlations']:
        print(f"  {c['col1']} <-> {c['col2']}: {c['correlation']}")
欠損データのパターン
from scripts.profiling import profile_missing_patterns

missing = profile_missing_patterns(df)

for col, stats in missing.items():
    if col != 'co_missing_columns':
        print(f"{col}: {stats['percent']}% missing, max {stats['consecutive_max']} consecutive")

# Check for columns missing together
if 'co_missing_columns' in missing:
    for col1, col2, pct in missing['co_missing_columns']:
        print(f"{col1} and {col2} both missing {pct}% of time")

プロファイル出力スキーマ

shape: [rows, columns]
memory_mb: float
columns:
  column_name:
    dtype: string
    null_count: int
    null_pct: float
    unique_count: int
    unique_pct: float
    # Numeric columns add:
    min: float
    max: float
    mean: float
    std: float
    median: float
    zeros: int
    negatives: int
    # String columns add:
    min_length: int
    max_length: int
    top_values: {value: count}
    # Datetime columns add:
    min_date: string
    max_date: string
    date_range_days: int

分析項目

数値列
  • 最小値、最大値、範囲、平均値、中央値、最頻値
  • 標準偏差、分散、歪度、尖度
  • パーセンタイル(5、25、50、75、95)
  • ゼロの件数、負の値の件数
  • 外れ値の検出(IQR 法)
文字列列
  • 最小/最大/平均の長さ
  • パターン分析(メールアドレス、電話番号、URL)
  • 出現頻度の高い上位 N 件の値
  • 空白文字の問題(先頭/末尾)
  • 大文字/小文字の分布(大文字/小文字/混在)
  • 空文字列の件数
日時列
  • 最小/最大の日付、日付範囲
  • 連続する日付の欠損
  • 曜日の分布
  • 時刻の分布(タイムスタンプの場合)
カテゴリ列
  • カーディナリティ、値の分布
  • 不均衡率
  • 希少カテゴリ(1% 未満)

相関分析

correlation_matrix = df.select_dtypes(include=[np.number]).corr()

# Highly correlated pairs (> 0.8)
high_corr = []
for i in range(len(correlation_matrix.columns)):
    for j in range(i+1, len(correlation_matrix.columns)):
        if abs(correlation_matrix.iloc[i, j]) > 0.8:
            high_corr.append((
                correlation_matrix.columns[i],
                correlation_matrix.columns[j],
                correlation_matrix.iloc[i, j]
            ))

品質フラグ

以下を自動的にフラグ付けします。

  • 高い欠損率: 欠損値が 50% 超
  • 定数列: 一意な値が 1 つのみ
  • 高カーディナリティ: 一意な値の比率が 95% 超(ID の可能性)
  • 重複の疑い: キー列に基づいて判定
  • データ型の不一致: 数値が文字列として保存されている
  • 未来の日付: 今日より後の日付
  • 負の値: 通常は正の値を取る列に含まれる負の値

レポートのセクション

エグゼクティブサマリー
  • データセットの形状(行数 x 列数)、メモリ使用量
  • 全体的な品質スコア、重大な問題の件数
列ごとの分析
  • 統計情報の表、分布ヒストグラム(ターミナルでは ASCII 形式)
  • 上位の値(カテゴリ列の場合)、品質に関する警告
関係性
  • 相関ヒートマップの概要
  • 外部キーとなり得る関係、列間の依存関係
推奨事項
  • 推奨するデータ型の最適化
  • 調査が必要な列、設定候補となるデータ品質ルール

出力形式

  • Markdown レポート: 表を含む詳細なレポート
  • JSON サマリー: プログラムで利用できる機械可読なプロファイル
  • HTML ダッシュボード: グラフ付きのインタラクティブなレポート(ydata-profiling が利用可能な場合)

依存関係

pandas
numpy

コメント