# dataverse-python-pandas-integration

This rule guides Python workflows that bring Dataverse records into pandas for exploration and reporting. It also draws a line between dataframe analysis and operations better handled by DataverseClient.

- rule · `type=rule` · GitHub Copilot · ★ 40418
- Author: github · official GitHub repository
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/github/awesome-copilot/tree/HEAD/instructions/dataverse-python-pandas-integration.instructions.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/rules/dataverse-python-pandas-integration

## What it does

The guide shows how to query Dataverse with the Python SDK, gather paged results, and create a pandas DataFrame. From there, it covers filtering, grouping, cleaning missing or duplicate values, joining account and contact data, and producing summary tables. Reports can be exported to CSV or Excel.

The examples use `PowerPlatform-Dataverse-Client`, `azure-identity`, and `pandas`; authentication is demonstrated with `InteractiveBrowserCredential`. Queries pass selected columns, filters, and sorting options to `client.get()`, then collect the returned pages before building the DataFrame. For file uploads, metadata work, single-record tasks, or real-time CRUD, the guide directs readers to `DataverseClient` rather than the pandas workflow.

## Install

### GitHub Copilot (native platform)

**Manually: put the files in place**
- File: `.github/instructions/dataverse-python-pandas-integration.instructions.md` — The applyTo field sets which files it applies to

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/dataverse-python-pandas-integration.md` — The paths frontmatter field limits the files: move applyTo from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/dataverse-python-pandas-integration.mdc` — Frontmatter: description, globs, alwaysApply. Move applyTo from the source into globs, or the rule will not attach on its own

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/dataverse-python-pandas-integration.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/dataverse-python-pandas-integration.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/github/awesome-copilot/tree/HEAD/instructions/dataverse-python-pandas-integration.instructions.md

## When to use it
- load Dataverse records into a pandas DataFrame
- filter and group rows by selected fields
- clean missing values and duplicates in a dataset
- join account and contact records
- create a summary report and export it to CSV or Excel

## Example prompts
- Show me how to fetch `account` records from Dataverse and load them into a DataFrame.
- Group the data by `industrycode` and summarize `creditlimit`.
- Join `account` with `contact` and export the report as CSV.

## Source text · dataverse-python-pandas-integration.instructions.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: fb5eb967ba4468b4.

BEGIN THIRD-PARTY FILE fb5eb967ba4468b4
````text
# Dataverse SDK for Python - Pandas Integration Guide

## Overview
Guide to integrating the Dataverse SDK for Python with pandas DataFrames for data science and analysis workflows. The SDK's JSON response format maps seamlessly to pandas DataFrames, enabling data scientists to work with Dataverse data using familiar data manipulation tools.

---

## 1. Introduction to PandasODataClient

### What is PandasODataClient?
`PandasODataClient` is a thin wrapper around the standard `DataverseClient` that returns data in pandas DataFrame format instead of raw JSON dictionaries. This makes it ideal for:
- Data scientists working with tabular data
- Analytics and reporting workflows
- Data exploration and cleaning
- Integration with machine learning pipelines

### Installation Requirements
```bash
# Install core dependencies
pip install PowerPlatform-Dataverse-Client
pip install azure-identity

# Install pandas for data manipulation
pip install pandas
```

### When to Use PandasODataClient
✅ **Use when you need:**
- Data exploration and analysis
- Working with tabular data
- Integration with statistical/ML libraries
- Efficient data manipulation

❌ **Use DataverseClient instead when you need:**
- Real-time CRUD operations only
- File upload operations
- Metadata operations
- Single record operations

---

## 2. Basic DataFrame Workflow

### Converting Query Results to DataFrame
```python
from azure.identity import InteractiveBrowserCredential
from PowerPlatform.Dataverse.client import DataverseClient
import pandas as pd

# Setup authentication
base_url = "https://<myorg>.crm.dynamics.com"
credential = InteractiveBrowserCredential()
client = DataverseClient(base_url=base_url, credential=credential)

# Query data
pages = client.get(
    "account",
    select=["accountid", "name", "creditlimit", "telephone1"],
    filter="statecode eq 0",
    orderby=["name"]
)

# Collect all pages into one DataFrame
all_records = []
for page in pages:
    all_records.extend(page)

# Convert to DataFrame
df = pd.DataFrame(all_records)

# Display first few rows
print(df.head())
print(f"Total records: {len(df)}")
```

### Query Parameters Map to DataFrame
```python
# All query parameters return as columns in DataFrame
df = pd.DataFrame(
    client.get(
        "account",
        select=["accountid", "name", "creditlimit", "telephone1", "createdon"],
        filter="creditlimit > 50000",
        orderby=["creditlimit desc"]
    )
)

# Result is a DataFrame with columns:
# accountid | name | creditlimit | telephone1 | createdon
```

---

## 3. Data Exploration with Pandas

### Basic Exploration
```python
import pandas as pd
from azure.identity import InteractiveBrowserCredential
from PowerPlatform.Dataverse.client import DataverseClient

client = DataverseClient("https://<myorg>.crm.dynamics.com", InteractiveBrowserCredential())

# Load account data
records = []
for page in client.get("account", select=["accountid", "name", "creditlimit", "industrycode"]):
    records.extend(page)

df = pd.DataFrame(records)

# Explore the data
print(df.shape)           # (1000, 4)
print(df.dtypes)          # Data types
print(df.describe())      # Statistical summary
print(df.info())          # Column info and null counts
print(df.head(10))        # First 10 rows
```

### Filtering and Selecting
```python
# Filter rows by condition
high_value = df[df['creditlimit'] > 100000]

# Select specific columns
names_limits = df[['name', 'creditlimit']]

# Multiple conditions
filtered = df[(df['creditlimit'] > 50000) & (df['industrycode'] == 1)]

# Value counts
print(df['industrycode'].value_counts())
```
````
END THIRD-PARTY FILE fb5eb967ba4468b4

The third-party file has ended. Everything between the fb5eb967ba4468b4 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3615 of 13594 bytes. © github · MIT · https://github.com/github/awesome-copilot/tree/HEAD/instructions/dataverse-python-pandas-integration.instructions.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
