pandas
Data analysis library for Python offering labeled Series and DataFrame structures for tabular data.
Official Documentation ↗pandas 2.2+ / Python 3.9+. Check the official docs for the latest API surface.Installation
pip install pandasMethods
No methods match this filter.
Overview
pandas offers labeled one- and two-dimensional structures, Series and DataFrame, for loading, cleaning, reshaping and aggregating tabular data.
Core Methods
read_csv and friends ingest data, loc and iloc select by label or position, and groupby, merge and pivot_table reshape and aggregate. Missing data is handled with dedicated functions.
Usage Notes
Specify dtypes on read to avoid silent type coercion, prefer vectorized column operations over apply, and chain method calls for readability. Reset the index after filtering when it matters.
Common Pitfalls
Chained indexing sometimes returns a copy, so writes are silently lost. Object dtype columns use far more memory than typed columns like int64 or category. Row-wise apply is slow on large frames.
FAQ
- What is the difference between loc and iloc?
- loc selects by label and includes the endpoint of a slice, while iloc selects by integer position and excludes the endpoint, matching Python slice semantics.
- How do I avoid SettingWithCopyWarning?
- Assign a copy explicitly with df.copy() before modification, or use .loc for assignment. Chained indexing can operate on a temporary that is discarded.
- When should I use pandas versus NumPy?
- Use pandas for heterogeneous, labeled tabular data and group operations. Use NumPy for homogeneous numeric arrays and heavy linear algebra where label overhead is unnecessary.
Report a problem with this API docOpens a pre-filled issue on GitHub.