jpskill.com
📦 その他 コミュニティ

datacommons-client

Data Commonsのプラットフォームを通じて、人口統計や経済指標、健康統計などの公開されている統計データにプログラムからアクセスし、データの検索や関連性の分析を行うSkill。

📜 元の英語説明(参考)

Work with Data Commons, a platform providing programmatic access to public statistical data from global sources. Use this skill when working with demographic data, economic indicators, health statistics, environmental data, or any public datasets available through Data Commons. Applicable for querying population statistics, GDP figures, unemployment rates, disease prevalence, geographic entity resolution, and exploring relationships between statistical entities.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Data Commonsのプラットフォームを通じて、人口統計や経済指標、健康統計などの公開されている統計データにプログラムからアクセスし、データの検索や関連性の分析を行うSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o datacommons-client.zip https://jpskill.com/download/18381.zip && unzip -o datacommons-client.zip && rm datacommons-client.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18381.zip -OutFile "$d\datacommons-client.zip"; Expand-Archive "$d\datacommons-client.zip" -DestinationPath $d -Force; ri "$d\datacommons-client.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して datacommons-client.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → datacommons-client フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
5

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Data Commons Client

概要

統計観測のクエリ、ナレッジグラフの探索、エンティティ識別子の解決のための、Data Commons Python API v2 への包括的なアクセスを提供します。Data Commons は、国勢調査局、保健機関、環境機関、その他の信頼できる情報源からのデータを統合し、統一されたナレッジグラフを構築します。

インストール

Pandas をサポートする Data Commons Python クライアントをインストールします。

uv pip install "datacommons-client[Pandas]"

Pandas を使用しない基本的な使用法の場合:

uv pip install datacommons-client

主要な機能

Data Commons API は、3 つの主要なエンドポイントで構成されており、それぞれ専用のリファレンスファイルで詳細に説明されています。

1. Observation エンドポイント - 統計データクエリ

エンティティの時系列統計データをクエリします。包括的なドキュメントについては、references/observation.md を参照してください。

主なユースケース:

  • 人口、経済、健康、または環境統計の取得
  • 傾向分析のための過去の時系列データへのアクセス
  • 階層構造のデータのクエリ (州内のすべての郡、地域内のすべての国)
  • 複数のエンティティ間の統計の比較
  • 一貫性のためのデータソースによるフィルタリング

一般的なパターン:

from datacommons_client import DataCommonsClient

client = DataCommonsClient()

# 最新の人口データを取得
response = client.observation.fetch(
    variable_dcids=["Count_Person"],
    entity_dcids=["geoId/06"],  # カリフォルニア州
    date="latest"
)

# 時系列を取得
response = client.observation.fetch(
    variable_dcids=["UnemploymentRate_Person"],
    entity_dcids=["country/USA"],
    date="all"
)

# 階層構造でクエリ
response = client.observation.fetch(
    variable_dcids=["MedianIncome_Household"],
    entity_expression="geoId/06<-containedInPlace+{typeOf:County}",
    date="2020"
)

2. Node エンドポイント - ナレッジグラフの探索

ナレッジグラフ内のエンティティの関係とプロパティを探索します。包括的なドキュメントについては、references/node.md を参照してください。

主なユースケース:

  • エンティティで利用可能なプロパティの発見
  • 地理的階層のナビゲート (親子関係)
  • エンティティ名とメタデータの取得
  • エンティティ間の接続の探索
  • グラフ内のすべてのエンティティタイプのリスト表示

一般的なパターン:

# プロパティを発見
labels = client.node.fetch_property_labels(
    node_dcids=["geoId/06"],
    out=True
)

# 階層をナビゲート
children = client.node.fetch_place_children(
    node_dcids=["country/USA"]
)

# エンティティ名を取得
names = client.node.fetch_entity_names(
    node_dcids=["geoId/06", "geoId/48"]
)

3. Resolve エンドポイント - エンティティの識別

エンティティ名、座標、または外部 ID を Data Commons ID (DCID) に変換します。包括的なドキュメントについては、references/resolve.md を参照してください。

主なユースケース:

  • クエリのために場所名を DCID に変換
  • 座標を場所に解決
  • Wikidata ID を Data Commons エンティティにマッピング
  • あいまいなエンティティ名の処理

一般的なパターン:

# 名前で解決
response = client.resolve.fetch_dcids_by_name(
    names=["California", "Texas"],
    entity_type="State"
)

# 座標で解決
dcid = client.resolve.fetch_dcid_by_coordinates(
    latitude=37.7749,
    longitude=-122.4194
)

# Wikidata ID を解決
response = client.resolve.fetch_dcids_by_wikidata_id(
    wikidata_ids=["Q30", "Q99"]
)

典型的なワークフロー

ほとんどの Data Commons クエリは、次のパターンに従います。

  1. エンティティを解決 (名前から始める場合):

    resolve_response = client.resolve.fetch_dcids_by_name(
        names=["California", "Texas"]
    )
    dcids = [r["candidates"][0]["dcid"]
             for r in resolve_response.to_dict().values()
             if r["candidates"]]
  2. 利用可能な変数を検出 (オプション):

    variables = client.observation.fetch_available_statistical_variables(
        entity_dcids=dcids
    )
  3. 統計データをクエリ:

    response = client.observation.fetch(
        variable_dcids=["Count_Person", "UnemploymentRate_Person"],
        entity_dcids=dcids,
        date="latest"
    )
  4. 結果を処理:

    # 辞書として
    data = response.to_dict()
    
    # Pandas DataFrame として
    df = response.to_observations_as_records()

統計変数の検索

統計変数は、Data Commons で特定の命名パターンを使用します。

一般的な変数のパターン:

  • Count_Person - 総人口
  • Count_Person_Female - 女性人口
  • UnemploymentRate_Person - 失業率
  • Median_Income_Household - 世帯収入の中央値
  • Count_Death - 死亡数
  • Median_Age_Person - 年齢の中央値

検出方法:

# エンティティで利用可能な変数をチェック
available = client.observation.fetch_available_statistical_variables(
    entity_dcids=["geoId/06"]
)

# または、Web インターフェースで探索
# https://datacommons.org/tools/statvar

Pandas の使用

すべての observation レスポンスは Pandas と統合されています。

response = client.observation.fetch(
    variable_dcids=["Count_Person"],
    entity_dcids=["geoId/06", "geoId/48"],
    date="all"
)

# DataFrame に変換
df = response.to_observations_as_records()
# カラム: date, entity, variable, value

# 分析のために再形成
pivot = df.pivot_table(
    values='value',
    index='date',
    columns='entity'
)

API 認証

datacommons.org (デフォルト) の場合:

  • API キーが必要です
  • 環境変数で設定: export DC_API_KEY="your_key"
  • または初期化時に渡す: client = DataCommonsClient(api_key="your_key")
  • キーのリクエスト: https://apikeys.datacommons.org/

カスタム Data Commons インスタンスの場合:

  • API キーは不要です
  • カスタムエンドポイントを指定: client = DataCommonsClient(url="https://custom.datacommons.org")

リファレンスドキュメント

各エンドポイントの包括的なドキュメントは、references/ ディレクトリにあります。

  • references/observation.md: 完全な Observation API ドキュメント
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Data Commons Client

Overview

Provides comprehensive access to the Data Commons Python API v2 for querying statistical observations, exploring the knowledge graph, and resolving entity identifiers. Data Commons aggregates data from census bureaus, health organizations, environmental agencies, and other authoritative sources into a unified knowledge graph.

Installation

Install the Data Commons Python client with Pandas support:

uv pip install "datacommons-client[Pandas]"

For basic usage without Pandas:

uv pip install datacommons-client

Core Capabilities

The Data Commons API consists of three main endpoints, each detailed in dedicated reference files:

1. Observation Endpoint - Statistical Data Queries

Query time-series statistical data for entities. See references/observation.md for comprehensive documentation.

Primary use cases:

  • Retrieve population, economic, health, or environmental statistics
  • Access historical time-series data for trend analysis
  • Query data for hierarchies (all counties in a state, all countries in a region)
  • Compare statistics across multiple entities
  • Filter by data source for consistency

Common patterns:

from datacommons_client import DataCommonsClient

client = DataCommonsClient()

# Get latest population data
response = client.observation.fetch(
    variable_dcids=["Count_Person"],
    entity_dcids=["geoId/06"],  # California
    date="latest"
)

# Get time series
response = client.observation.fetch(
    variable_dcids=["UnemploymentRate_Person"],
    entity_dcids=["country/USA"],
    date="all"
)

# Query by hierarchy
response = client.observation.fetch(
    variable_dcids=["MedianIncome_Household"],
    entity_expression="geoId/06<-containedInPlace+{typeOf:County}",
    date="2020"
)

2. Node Endpoint - Knowledge Graph Exploration

Explore entity relationships and properties within the knowledge graph. See references/node.md for comprehensive documentation.

Primary use cases:

  • Discover available properties for entities
  • Navigate geographic hierarchies (parent/child relationships)
  • Retrieve entity names and metadata
  • Explore connections between entities
  • List all entity types in the graph

Common patterns:

# Discover properties
labels = client.node.fetch_property_labels(
    node_dcids=["geoId/06"],
    out=True
)

# Navigate hierarchy
children = client.node.fetch_place_children(
    node_dcids=["country/USA"]
)

# Get entity names
names = client.node.fetch_entity_names(
    node_dcids=["geoId/06", "geoId/48"]
)

3. Resolve Endpoint - Entity Identification

Translate entity names, coordinates, or external IDs into Data Commons IDs (DCIDs). See references/resolve.md for comprehensive documentation.

Primary use cases:

  • Convert place names to DCIDs for queries
  • Resolve coordinates to places
  • Map Wikidata IDs to Data Commons entities
  • Handle ambiguous entity names

Common patterns:

# Resolve by name
response = client.resolve.fetch_dcids_by_name(
    names=["California", "Texas"],
    entity_type="State"
)

# Resolve by coordinates
dcid = client.resolve.fetch_dcid_by_coordinates(
    latitude=37.7749,
    longitude=-122.4194
)

# Resolve Wikidata IDs
response = client.resolve.fetch_dcids_by_wikidata_id(
    wikidata_ids=["Q30", "Q99"]
)

Typical Workflow

Most Data Commons queries follow this pattern:

  1. Resolve entities (if starting with names):

    resolve_response = client.resolve.fetch_dcids_by_name(
        names=["California", "Texas"]
    )
    dcids = [r["candidates"][0]["dcid"]
             for r in resolve_response.to_dict().values()
             if r["candidates"]]
  2. Discover available variables (optional):

    variables = client.observation.fetch_available_statistical_variables(
        entity_dcids=dcids
    )
  3. Query statistical data:

    response = client.observation.fetch(
        variable_dcids=["Count_Person", "UnemploymentRate_Person"],
        entity_dcids=dcids,
        date="latest"
    )
  4. Process results:

    # As dictionary
    data = response.to_dict()
    
    # As Pandas DataFrame
    df = response.to_observations_as_records()

Finding Statistical Variables

Statistical variables use specific naming patterns in Data Commons:

Common variable patterns:

  • Count_Person - Total population
  • Count_Person_Female - Female population
  • UnemploymentRate_Person - Unemployment rate
  • Median_Income_Household - Median household income
  • Count_Death - Death count
  • Median_Age_Person - Median age

Discovery methods:

# Check what variables are available for an entity
available = client.observation.fetch_available_statistical_variables(
    entity_dcids=["geoId/06"]
)

# Or explore via the web interface
# https://datacommons.org/tools/statvar

Working with Pandas

All observation responses integrate with Pandas:

response = client.observation.fetch(
    variable_dcids=["Count_Person"],
    entity_dcids=["geoId/06", "geoId/48"],
    date="all"
)

# Convert to DataFrame
df = response.to_observations_as_records()
# Columns: date, entity, variable, value

# Reshape for analysis
pivot = df.pivot_table(
    values='value',
    index='date',
    columns='entity'
)

API Authentication

For datacommons.org (default):

  • An API key is required
  • Set via environment variable: export DC_API_KEY="your_key"
  • Or pass when initializing: client = DataCommonsClient(api_key="your_key")
  • Request keys at: https://apikeys.datacommons.org/

For custom Data Commons instances:

  • No API key required
  • Specify custom endpoint: client = DataCommonsClient(url="https://custom.datacommons.org")

Reference Documentation

Comprehensive documentation for each endpoint is available in the references/ directory:

  • references/observation.md: Complete Observation API documentation with all methods, parameters, response formats, and common use cases
  • references/node.md: Complete Node API documentation for graph exploration, property queries, and hierarchy navigation
  • references/resolve.md: Complete Resolve API documentation for entity identification and DCID resolution
  • references/getting_started.md: Quickstart guide with end-to-end examples and common patterns

Additional Resources

Tips for Effective Use

  1. Always start with resolution: Convert names to DCIDs before querying data
  2. Use relation expressions for hierarchies: Query all children at once instead of individual queries
  3. Check data availability first: Use fetch_available_statistical_variables() to see what's queryable
  4. Leverage Pandas integration: Convert responses to DataFrames for analysis
  5. Cache resolutions: If querying the same entities repeatedly, store name→DCID mappings
  6. Filter by facet for consistency: Use filter_facet_domains to ensure data from the same source
  7. Read reference docs: Each endpoint has extensive documentation in the references/ directory

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。