---
title: "DataFrame"
description: "A DataFrame is a two-dimensional data structure that organizes data into rows and columns, similar to a spreadsheet or database table."
canonical: "https://motherduck.com/glossary/dataframe/"
related:
  - title: "Why Python Developers Need DuckDB (And Not Just Another DataFrame Library)"
    url: "https://motherduck.com/blog/python-duckdb-vs-dataframe-libraries/"
  - title: "DuckLake | MotherDuck Docs"
    url: "https://motherduck.com/docs/concepts/ducklake/"
  - title: "Data-based: Going Beyond the Dataframe | MotherDuck"
    url: "https://motherduck.com/videos/going-beyond-the-dataframe/"
gated_asset:
  title: "DuckLake on MotherDuck"
  url: "https://motherduck.com/product/ducklake/"
---

# DataFrame

> A DataFrame is a two-dimensional data structure that organizes data into rows and columns, similar to a spreadsheet or database table.

## Overview

A [DataFrame](https://motherduck.com/learn/dataframes/) is a two-dimensional data structure that organizes data into rows and columns, similar to a spreadsheet or database table. DataFrames have become the standard way to work with structured data in Python, R, and other data analysis languages, with [pandas](https://pandas.pydata.org/) being the most popular DataFrame implementation in Python.

<glossary-callout guide="duckdb-book-brief" />

## Key Characteristics

DataFrames store data in labeled columns where each column can contain a different data type (like integers, text, dates, etc). Unlike simple tables, DataFrames provide built-in methods for data manipulation, filtering, grouping, and analysis. Column names allow for intuitive access to data, while index labels help identify specific rows.

## DuckDB Integration 

DuckDB seamlessly integrates with pandas DataFrames through its Python API. You can query DataFrames directly using SQL with `duckdb.sql()`, or convert DuckDB query results to DataFrames using `.df()`. This allows you to combine the performance benefits of DuckDB's query engine with the familiar pandas interface.

For example, you can query a pandas DataFrame directly:

```python
import duckdb
import pandas as pd

df = pd.DataFrame({'name': ['Alice', 'Bob'], 'age': [25, 30]})
result = duckdb.sql("SELECT * FROM df WHERE age > 25")
```

Or convert DuckDB results to a DataFrame:

```python
duckdb_result = duckdb.sql("SELECT * FROM my_table")
pandas_df = duckdb_result.df()
```

## Common Implementations

Beyond pandas, other popular DataFrame implementations include:
- [polars](https://pola.rs/) - A fast DataFrame library written in Rust
- [Apache Arrow](https://arrow.apache.org/) - A cross-language development platform for in-memory analytics
- [R data.frame](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/data.frame) - The original DataFrame implementation in R
- [Spark DataFrame](https://spark.apache.org/docs/latest/sql-programming-guide.html) - Distributed DataFrames for big data processing

DuckDB can interact with most of these DataFrame implementations, making it a versatile tool in the modern data stack.



**Watch:** [DuckDB vs Pandas vs Polars: Performance Comparison for Python](https://motherduck.com/videos/duckdb-vs-pandas-vs-polars-for-python-devs/)
