pandas: Python Data Analysis Toolkit
pandas is the library most Python data work runs through before anything else touches the data: read a CSV, get a DataFrame, start slicing. Its groupby, merge, and pivot_table operations cover most analysis tasks that would otherwise mean hand-rolled loops or a trip to SQL. The catch is memory — a DataFrame lives entirely in RAM, so pandas gets uncomfortable once a file stops fitting on one machine.
What is pandas?
pandas is a Python library for tabular and time series data, built around two objects: the Series (one labeled column) and the DataFrame (a full table with labeled rows and columns). It reads CSV, Excel, SQL, and HDF5 sources straight into a DataFrame, then lets you filter, group, reshape, and merge that data with a small set of methods instead of nested loops. NumPy supplies the array machinery underneath.
Core features
- ✓Labeled data structures — Series and DataFrame carry row and column labels, so pandas DataFrame operations align data by label instead of raw position.
- ✓Missing-data handling — NaN, NA, and NaT values are handled consistently across floating-point and non-floating-point columns.
- ✓groupby split-apply-combine — group by operations for aggregating or transforming data without writing manual loops.
- ✓Flexible merging and joining — combine two datasets the way a database JOIN would, keyed on an index or a column.
- ✓Reshaping and pivoting — turn long data wide, or back, with pivot_table and related methods.
- ✓Hierarchical indexing (MultiIndex) — attach more than one label per row or column axis.
- ✓Broad I/O support — csv reading plus Excel, SQL database, and HDF5 read/write in the same API.
- ✓Time series analysis tools — date range generation, frequency conversion, and moving-window statistics built in.
Installing pandas
pandas installs the same way most Python packages do. Via pip: `pip install pandas`. Via conda: `conda install -c conda-forge pandas`. Both pull in pandas plus its required dependencies — NumPy, python-dateutil, and, on Windows or Emscripten, tzdata — from PyPI or conda-forge respectively. Building from source is more involved: you need Cython in addition to the normal dependencies, then run `pip install .` from inside the cloned `pandas` directory, or `python -m pip install -ve . --no-build-isolation --config-settings editable-verbose=true` for an editable, development install.
Working with DataFrames
The GitHub README doesn't walk through a worked example — it lists the operations and links out to pandas' own user guide for each one. In practice, working with a DataFrame comes down to three habits: load data with a `read_*` function (`read_csv`, `read_excel`, `read_sql`), refer to columns and rows by label instead of position, and reach for `groupby()`, `merge()`, or `pivot_table()` instead of a loop. Step-by-step usage beyond that isn't clearly documented in the repo itself — the linked user-guide pages on missing data, groupby, merging, reshaping, and indexing carry the actual worked examples.
Why developers choose pandas
- ✓The DataFrame API is documented in depth on PyData.org, so most operations have a canonical example to copy.
- ✓groupby, merge, and pivot_table replace a lot of hand-written aggregation logic with a few method calls.
- ✓Reads CSV, Excel, SQL, and HDF5 straight into the same DataFrame shape, so the input format stops mattering once it's loaded.
- ✓Sits directly on NumPy for numpy integration, so code already working with NumPy arrays interoperates without a conversion step.
Known limitations
- △A DataFrame is held entirely in memory — there's no built-in out-of-core or lazy execution, so a dataset bigger than RAM needs a different tool or chunked reading.
- △The method surface is large; chained calls like `.groupby().apply().reset_index()` get unreadable fast without time spent learning idiomatic pandas.
- △Building from source needs Cython on top of the normal dependencies — one more step than a plain pip install.
Alternatives to consider
Frequently asked questions
pandas is free and open source software, released under the BSD 3-Clause license. That means anyone can download, use, modify, and redistribute pandas without paying for a license, and the full source is public on GitHub at pandas-dev/pandas, where issues and pull requests are handled in the open.
pandas is released under the BSD 3-Clause license, a permissive open-source license. It allows using, modifying, and redistributing pandas in both open-source and closed-source projects, with minimal obligations beyond keeping the copyright notice intact — there's no copyleft requirement to open-source code that merely uses pandas.
pandas can be used for commercial projects. Its BSD 3-Clause license permits commercial use, so pandas can be bundled into a paid product or run internally at a company without a separate commercial license or royalty payment.
pandas is built around two data structures: the Series, a single labeled column of data, and the DataFrame, a full table of rows and columns with labels on both axes. Most pandas operations — filtering, grouping, merging — work on one or both of these objects.
pandas' DataFrame was modeled directly on R's data.frame, bringing the same labeled-row, labeled-column workflow into Python. The README states pandas aims to become the most capable and flexible open-source data analysis tool in any language — a goal the project sets for itself, not an independent comparison result.
pandas depends on NumPy for array and math operations, python-dateutil for extended datetime handling, and tzdata for time zone data, which is only required on Windows and Emscripten. All three install automatically with `pip install pandas`, so there's nothing extra to set up by hand for a standard install.
The problem it solves
Raw tabular data in Python — a CSV read into a list of dicts, or a NumPy array with no column names — has no memory of what its rows and columns mean. Every operation, filtering by date or summing by category, has to be rebuilt from scratch with index math or manual loops each time. pandas attaches labels to both axes so "rows where date > X" or "sum revenue by region" become one method call, and it folds CSV, Excel, SQL, and HDF5 input into the same DataFrame shape so the source format stops being the analysis's problem.
Best use cases
- •Cleaning a messy CSV or Excel export before it goes into a report or a model.
- •Aggregating transaction or log data by day, category, or user with groupby.
- •Joining two datasets — orders and customers, say — on a shared key.
- •Running time series analysis on a metric: resampling to weekly totals, computing rolling averages.
Who should try it — and who should skip
Anyone doing exploratory data analysis, ETL scripts, or reporting in Python is the target user — the CSV-to-chart-to-report loop is what pandas was built for. Skip it, or at least don't start there, if the data already lives in a warehouse and a SQL query would answer the question faster, or if the dataset is too large for one machine's RAM and you'd be reaching for chunked workarounds from day one.
Related repositories
Still deciding about pandas?
One click hands the question to an AI along with this page — see what it says about pandas.
