What is pandas?

In short
pandas is an open source Python library for working with tabular data, such as spreadsheets and database tables. It gives you two main structures, the Series and the DataFrame, plus tools to clean, filter, group and analyze that data. It is released under the BSD license and is widely used in data analysis and machine learning work.
pandas is a library for the Python programming language. A library is a set of ready-made code that you add to your project so you do not have to write common tasks from scratch. The name is short for "panel data", a term from statistics, but most people simply use it for working with tables of data.
If you have ever opened a spreadsheet, you already know the basic idea. Rows hold records, and columns hold fields such as a name, a date or a price. pandas lets you load that kind of table into Python, change it, and answer questions about it with a few lines of code.
How it works
The official documentation describes pandas as a library that provides data structures and data analysis tools. Two structures do most of the work:
- A Series is a single column of values, with a label for each row.
- A DataFrame is a full table made of several columns that share the same row labels.
You create these objects in Python, then call methods on them. A method is a function attached to an object. For example, you can select rows that match a condition, sort the table, or compute an average for each group. Because the operations are written for whole columns at once, they are much faster than looping over every value yourself.
pandas also reads and writes common file formats, such as CSV files, so the data you need often comes in with a single function call.
When to use it
pandas fits best when your data has a table-like shape and you want to explore or prepare it before doing something else with it. Typical uses include:
- Cleaning a messy export, for example removing empty rows or fixing column types.
- Combining two tables with a shared key, similar to a join in a database.
- Grouping records and calculating totals or averages for each group.
- Preparing a dataset before you train a machine learning model.
If you are learning machine learning, you will meet pandas very early. Many tutorials load their data into a DataFrame first, then pass the cleaned values to other libraries. If you are new to that workflow, our page on Jupyter Notebook explains the environment many people use to run pandas code step by step.
A simple example
The following short example builds a small table and asks a simple question about it. You need Python and pandas installed first.
import pandas as pd
sales = pd.DataFrame({
"city": ["Oslo", "Lyon", "Oslo", "Lyon"],
"amount": [120, 95, 80, 140],
})
totals = sales.groupby("city")["amount"].sum()
print(totals)
The line import pandas as pd loads the library under a short name, which is the convention used in almost every example online. The DataFrame holds four rows. The groupby method splits the rows by city, and sum adds up the amounts in each group. The output shows one total per city.
Notice that you did not write a loop. You describe what you want, and pandas performs the work across the whole column.
Common mistakes
Beginners often run into a few problems with pandas:
- Forgetting that many methods return a new object instead of changing the original. If you want to keep the result, assign it to a variable.
- Mixing up a Series and a DataFrame. Selecting one column with single brackets gives a Series, while a list of column names gives a DataFrame.
- Assuming that the data types are correct. A column of numbers stored as text will not add up until you convert it.
- Reading the API reference too early. The reference describes every parameter in detail, but it assumes you already understand the key concepts. The user guide is a better place to start.
The official documentation is organized into a getting started section, a user guide, an API reference and a developer guide. Beginners usually benefit most from the getting started material and the user guide before moving to the reference.
Alternatives
pandas is not the only option for tabular data. Other tools may suit you better in some situations:
- Spreadsheet programs are simpler for small, one-off tasks and for people who prefer a visual interface.
- SQL databases are a good choice when data is large, shared between applications, or already stored in a database.
- Other Python libraries focus on very large datasets or on speed in specific cases.
For most beginners working in Python, pandas is a practical first choice. It is the standard tool for exploring tables in Python and it has a large community that has written tutorials for almost every common task.
FAQ
Is pandas free to use?
Yes. pandas is an open source library released under the BSD license. You can use it in personal and commercial projects.
Do I need to know Python before learning pandas?
Yes, you should know the basics of Python, such as variables, lists and functions. pandas is a Python library, so its examples are written in Python code.
What is the difference between a Series and a DataFrame?
A Series holds one column of values with row labels. A DataFrame is a full table made of several Series that share the same row labels.
Can pandas read spreadsheet and CSV files?
Yes. pandas can read and write common formats such as CSV files, so you can load data from a file with a single function call.
Where should I start with the official documentation?
Start with the getting started guides and the user guide. The API reference is more useful once you understand the main concepts.
Sources
This page is based on the official documentation below. Read it for full detail.
pandas — official documentation ↗pandas in the news
Anthropic Ports Claude API From Python to Rust Using Production Traffic as the Test
Anthropic says it rewrote its Messages API from Python to Rust without downtime, cutting CPU use by about 70%. The main challenge was verifying the new code, which it did by comparing live traffic against the old service.
