pandas-ai
PandasAIは、普段使っているpandasのデータフレームに対して、難しいコードを書かずに自然な言葉で質問したり、グラフを作ったり、データを整理したりできる、会話形式でデータ分析を簡単にするSkill。
📜 元の英語説明(参考)
PandasAI enables natural language queries on pandas DataFrames using LLMs. Learn to ask questions in plain English, generate charts, clean data, and integrate with OpenAI and local models for conversational data analysis.
🇯🇵 日本人クリエイター向け解説
PandasAIは、普段使っているpandasのデータフレームに対して、難しいコードを書かずに自然な言葉で質問したり、グラフを作ったり、データを整理したりできる、会話形式でデータ分析を簡単にするSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o pandas-ai.zip https://jpskill.com/download/15231.zip && unzip -o pandas-ai.zip && rm pandas-ai.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15231.zip -OutFile "$d\pandas-ai.zip"; Expand-Archive "$d\pandas-ai.zip" -DestinationPath $d -Force; ri "$d\pandas-ai.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
pandas-ai.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
pandas-aiフォルダができる - 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 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
PandasAI
PandasAI は、pandas に自然言語機能を追加します。英語でデータに関する質問をすると、LLM を利用して回答、グラフ、変換が得られます。
インストール
# PandasAI のインストール
pip install pandasai
# OpenAI を使用する場合
pip install pandasai[openai]
# Ollama 経由でローカルモデルを使用する場合
pip install pandasai[langchain]
基本的な使い方
# basic.py: 自然言語で DataFrame について質問する
import pandas as pd
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
llm = OpenAI(api_token="your-openai-api-key")
df = pd.DataFrame({
"country": ["USA", "UK", "France", "Germany", "Japan"],
"population": [331_000_000, 67_000_000, 67_000_000, 83_000_000, 125_000_000],
"gdp_billion": [25_460, 3_070, 2_780, 4_070, 4_230],
})
sdf = SmartDataframe(df, config={"llm": llm})
# 自然言語で質問する
answer = sdf.chat("Which country has the highest GDP?")
print(answer) # USA
answer = sdf.chat("What is the average population?")
print(answer) # 134,600,000
answer = sdf.chat("List countries with GDP above 4000 billion")
print(answer)
複数の DataFrame
# multi-df.py: 複数の関連する DataFrame に対してクエリを実行する
from pandasai import SmartDatalake
employees = pd.DataFrame({
"id": [1, 2, 3, 4, 5],
"name": ["Alice", "Bob", "Charlie", "Diana", "Eve"],
"department_id": [1, 2, 1, 3, 2],
"salary": [85000, 72000, 90000, 68000, 95000],
})
departments = pd.DataFrame({
"id": [1, 2, 3],
"name": ["Engineering", "Marketing", "Sales"],
"budget": [500000, 200000, 300000],
})
lake = SmartDatalake([employees, departments], config={"llm": llm})
result = lake.chat("What is the average salary per department?")
print(result)
result = lake.chat("Which department is over budget based on total salaries?")
print(result)
グラフの生成
# charts.py: 自然言語から可視化を作成する
sdf = SmartDataframe(df, config={
"llm": llm,
"save_charts": True,
"save_charts_path": "./charts",
})
# 質問することでグラフを生成する
sdf.chat("Create a bar chart of GDP by country")
sdf.chat("Plot a pie chart of population distribution")
sdf.chat("Show a scatter plot of GDP vs population")
# グラフは PNG として ./charts/ に保存されます
データのクリーニング
# cleaning.py: 自然言語をデータクリーニングタスクに使用する
dirty_df = pd.DataFrame({
"name": ["Alice", "bob", "CHARLIE", None, "Eve"],
"email": ["alice@co.com", "invalid", "charlie@co.com", "diana@co.com", ""],
"age": [30, -5, 45, 200, 28],
"salary": [85000, 72000, None, 68000, 95000],
})
sdf = SmartDataframe(dirty_df, config={"llm": llm})
# 自然言語でクリーニングする
cleaned = sdf.chat("Remove rows where age is negative or above 150")
cleaned = sdf.chat("Fill missing salaries with the median salary")
cleaned = sdf.chat("Standardize names to title case")
cleaned = sdf.chat("Remove rows with invalid email addresses")
カスタム構成
# config.py: PandasAI の高度な構成
from pandasai import SmartDataframe
sdf = SmartDataframe(df, config={
"llm": llm,
"conversational": True, # 自然言語での応答
"verbose": True, # 生成されたコードを表示
"enable_cache": True, # 繰り返されるクエリをキャッシュ
"max_retries": 3, # LLM エラー時にリトライ
"custom_whitelisted_dependencies": ["scipy", "sklearn"],
"save_logs": True,
})
# 生成された Python コードを表示する
sdf.chat("What is the correlation between GDP and population?")
print(sdf.last_code_generated)
ローカルモデルの使用
# local-llm.py: OpenAI の代わりに Ollama または他のローカルモデルを使用する
from pandasai.llm.local_llm import LocalLLM
# ローカルで Ollama を実行している場合
llm = LocalLLM(api_base="http://localhost:11434/v1", model="llama3")
sdf = SmartDataframe(df, config={"llm": llm})
answer = sdf.chat("Summarize this dataset")
print(answer)
パイプラインの統合
# pipeline.py: 自動化された分析パイプラインで PandasAI を使用する
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
import pandas as pd
import json
def analyze_dataset(csv_path: str, questions: list[str]) -> dict:
"""CSV データセットに対して一連の自然言語の質問を実行します。"""
llm = OpenAI(api_token="your-key")
df = pd.read_csv(csv_path)
sdf = SmartDataframe(df, config={"llm": llm, "conversational": True})
results = {}
for question in questions:
try:
answer = sdf.chat(question)
results[question] = str(answer)
except Exception as e:
results[question] = f"Error: {e}"
return results
# 使用例
report = analyze_dataset("sales.csv", [
"What was the total revenue last month?",
"Which product category had the most sales?",
"What is the month-over-month growth rate?",
])
print(json.dumps(report, indent=2)) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
PandasAI
PandasAI adds natural language capabilities to pandas. Ask questions about your data in English and get answers, charts, and transformations — powered by LLMs.
Installation
# Install PandasAI
pip install pandasai
# With OpenAI
pip install pandasai[openai]
# With local models via Ollama
pip install pandasai[langchain]
Basic Usage
# basic.py: Ask questions about a DataFrame in natural language
import pandas as pd
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
llm = OpenAI(api_token="your-openai-api-key")
df = pd.DataFrame({
"country": ["USA", "UK", "France", "Germany", "Japan"],
"population": [331_000_000, 67_000_000, 67_000_000, 83_000_000, 125_000_000],
"gdp_billion": [25_460, 3_070, 2_780, 4_070, 4_230],
})
sdf = SmartDataframe(df, config={"llm": llm})
# Ask questions in natural language
answer = sdf.chat("Which country has the highest GDP?")
print(answer) # USA
answer = sdf.chat("What is the average population?")
print(answer) # 134,600,000
answer = sdf.chat("List countries with GDP above 4000 billion")
print(answer)
Multiple DataFrames
# multi-df.py: Query across multiple related DataFrames
from pandasai import SmartDatalake
employees = pd.DataFrame({
"id": [1, 2, 3, 4, 5],
"name": ["Alice", "Bob", "Charlie", "Diana", "Eve"],
"department_id": [1, 2, 1, 3, 2],
"salary": [85000, 72000, 90000, 68000, 95000],
})
departments = pd.DataFrame({
"id": [1, 2, 3],
"name": ["Engineering", "Marketing", "Sales"],
"budget": [500000, 200000, 300000],
})
lake = SmartDatalake([employees, departments], config={"llm": llm})
result = lake.chat("What is the average salary per department?")
print(result)
result = lake.chat("Which department is over budget based on total salaries?")
print(result)
Generate Charts
# charts.py: Create visualizations from natural language
sdf = SmartDataframe(df, config={
"llm": llm,
"save_charts": True,
"save_charts_path": "./charts",
})
# Generate charts by asking
sdf.chat("Create a bar chart of GDP by country")
sdf.chat("Plot a pie chart of population distribution")
sdf.chat("Show a scatter plot of GDP vs population")
# Charts saved as PNG in ./charts/
Data Cleaning
# cleaning.py: Use natural language for data cleaning tasks
dirty_df = pd.DataFrame({
"name": ["Alice", "bob", "CHARLIE", None, "Eve"],
"email": ["alice@co.com", "invalid", "charlie@co.com", "diana@co.com", ""],
"age": [30, -5, 45, 200, 28],
"salary": [85000, 72000, None, 68000, 95000],
})
sdf = SmartDataframe(dirty_df, config={"llm": llm})
# Clean with natural language
cleaned = sdf.chat("Remove rows where age is negative or above 150")
cleaned = sdf.chat("Fill missing salaries with the median salary")
cleaned = sdf.chat("Standardize names to title case")
cleaned = sdf.chat("Remove rows with invalid email addresses")
Custom Configuration
# config.py: Advanced PandasAI configuration
from pandasai import SmartDataframe
sdf = SmartDataframe(df, config={
"llm": llm,
"conversational": True, # Natural language responses
"verbose": True, # Show generated code
"enable_cache": True, # Cache repeated queries
"max_retries": 3, # Retry on LLM errors
"custom_whitelisted_dependencies": ["scipy", "sklearn"],
"save_logs": True,
})
# View the generated Python code
sdf.chat("What is the correlation between GDP and population?")
print(sdf.last_code_generated)
Using Local Models
# local-llm.py: Use Ollama or other local models instead of OpenAI
from pandasai.llm.local_llm import LocalLLM
# With Ollama running locally
llm = LocalLLM(api_base="http://localhost:11434/v1", model="llama3")
sdf = SmartDataframe(df, config={"llm": llm})
answer = sdf.chat("Summarize this dataset")
print(answer)
Pipeline Integration
# pipeline.py: Use PandasAI in an automated analysis pipeline
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
import pandas as pd
import json
def analyze_dataset(csv_path: str, questions: list[str]) -> dict:
"""Run a set of natural language questions against a CSV dataset."""
llm = OpenAI(api_token="your-key")
df = pd.read_csv(csv_path)
sdf = SmartDataframe(df, config={"llm": llm, "conversational": True})
results = {}
for question in questions:
try:
answer = sdf.chat(question)
results[question] = str(answer)
except Exception as e:
results[question] = f"Error: {e}"
return results
# Usage
report = analyze_dataset("sales.csv", [
"What was the total revenue last month?",
"Which product category had the most sales?",
"What is the month-over-month growth rate?",
])
print(json.dumps(report, indent=2))