pandas
Overview
pandas is a fast, flexible, and expressive Python library providing labeled data structures (Series, DataFrame) for working with relational and time-series data. It is the de facto tool for data loading, cleaning, transformation, and exploratory analysis, and feeds most ML and analytics workflows. Read this when wrangling tabular data, doing groupby/merge/pivot operations, or handling missing values and datetime indexes.
Official sources
Install / setup
pip install pandas
Command from the official install guide: https://pandas.pydata.org/docs/getting_started/install.html
Core concepts
- DataFrame — 2D labeled table with heterogeneous typed columns; the central data structure.
- Series — 1D labeled array; a single DataFrame column.
- Index — row/column labels enabling alignment; includes
DatetimeIndex and MultiIndex.
- Label vs position selection —
.loc[] selects by label, .iloc[] by integer position.
- groupby — split-apply-combine for aggregation and transformation over groups.
- merge / join / concat — SQL-style joins and stacking of DataFrames.
- reshape —
pivot/pivot_table, melt, stack/unstack to move between wide and long forms.
Best practices
Common pitfalls
- Chained assignment (
df[mask]['col'] = x) consistently never modifies the original under Copy-on-Write (default in pandas 3.0); no warning is raised (SettingWithCopyWarning was removed in 3.0) → use df.loc[mask, 'col'] = x.
- The
inplace= keyword is being deprecated (PDEP-8) for methods where it is only syntactic sugar for reassignment → prefer reassigning the result. It is retained for value-mutating methods (fillna, replace, ffill, bfill, interpolate, where, mask, clip), which in pandas 3.0 now return self instead of None.
- Mixing label and position with
.ix (removed) → use .loc/.iloc.
Examples
import pandas as pd
df = pd.read_csv("sales.csv", parse_dates=["date"])
df = df.dropna(subset=["amount"])
monthly = (
df.assign(month=df["date"].dt.to_period("M"))
.groupby(["month", "region"], as_index=False)["amount"]
.sum()
)
print(monthly.head())
Further reading
Related skills
- ../numpy — array engine underlying pandas
- ../scikit-learn — consumes DataFrames for ML
- ../jupyter — interactive notebooks for data exploration
1---2name: pandas3description: pandas is the standard Python library for labeled tabular data analysis and manipulation, providing the DataFrame and Series structures for loading, cleaning, reshaping, grouping, joining, and aggregating data. Consult this when reading/writing CSV/Parquet/Excel/SQL, filtering and selecting rows/columns with loc/iloc, handling missing data, doing groupby aggregations, merging/joining tables, pivoting/melting, working with time series and datetime indexes, or understanding Copy-on-Write (the default in pandas 3.0) and why chained assignment never modifies the original.4domain: stack5category: aiml6tags: [pandas, dataframe, data-analysis, data-wrangling, etl, time-series, python]7official_sources:8 - https://pandas.pydata.org/docs/9 - https://github.com/pandas-dev/pandas10 - https://pandas.pydata.org/docs/getting_started/install.html11verified: 2026-06-1712metadata:13 source: https://skillmd.com/skills/gabriel7silva/pandas14---1516# pandas1718## Overview19pandas is a fast, flexible, and expressive Python library providing labeled data structures (`Series`, `DataFrame`) for working with relational and time-series data. It is the de facto tool for data loading, cleaning, transformation, and exploratory analysis, and feeds most ML and analytics workflows. Read this when wrangling tabular data, doing groupby/merge/pivot operations, or handling missing values and datetime indexes.2021## Official sources22- Docs: https://pandas.pydata.org/docs/23- Repo: https://github.com/pandas-dev/pandas24- Install: https://pandas.pydata.org/docs/getting_started/install.html2526## Install / setup27```bash28pip install pandas29```30Command from the official install guide: https://pandas.pydata.org/docs/getting_started/install.html3132## Core concepts33- **DataFrame** — 2D labeled table with heterogeneous typed columns; the central data structure.34- **Series** — 1D labeled array; a single DataFrame column.35- **Index** — row/column labels enabling alignment; includes `DatetimeIndex` and `MultiIndex`.36- **Label vs position selection** — `.loc[]` selects by label, `.iloc[]` by integer position.37- **groupby** — split-apply-combine for aggregation and transformation over groups.38- **merge / join / concat** — SQL-style joins and stacking of DataFrames.39- **reshape** — `pivot`/`pivot_table`, `melt`, `stack`/`unstack` to move between wide and long forms.4041## Best practices42- Assign via `.loc`/`.iloc` (`df.loc[mask, 'col'] = x`) rather than chained indexing (`df[a][b] = x`); under Copy-on-Write (default in pandas 3.0) chained assignment silently does nothing to the original (https://pandas.pydata.org/docs/user_guide/copy_on_write.html).43- Use vectorized operations and built-in methods instead of `.iterrows()` loops (https://pandas.pydata.org/docs/user_guide/enhancingperf.html).44- Parse dates explicitly (`pd.to_datetime`, `parse_dates=`) and set a `DatetimeIndex` for time-series work (https://pandas.pydata.org/docs/user_guide/timeseries.html).45- Prefer columnar formats like Parquet over CSV for large data round-trips (https://pandas.pydata.org/docs/user_guide/io.html).4647## Common pitfalls48- Chained assignment (`df[mask]['col'] = x`) consistently never modifies the original under Copy-on-Write (default in pandas 3.0); no warning is raised (`SettingWithCopyWarning` was removed in 3.0) → use `df.loc[mask, 'col'] = x`.49- The `inplace=` keyword is being deprecated (PDEP-8) for methods where it is only syntactic sugar for reassignment → prefer reassigning the result. It is retained for value-mutating methods (`fillna`, `replace`, `ffill`, `bfill`, `interpolate`, `where`, `mask`, `clip`), which in pandas 3.0 now return `self` instead of `None`.50- Mixing label and position with `.ix` (removed) → use `.loc`/`.iloc`.5152## Examples53```python54import pandas as pd5556df = pd.read_csv("sales.csv", parse_dates=["date"])57df = df.dropna(subset=["amount"])58monthly = (59 df.assign(month=df["date"].dt.to_period("M"))60 .groupby(["month", "region"], as_index=False)["amount"]61 .sum()62)63print(monthly.head())64```6566## Further reading67- https://pandas.pydata.org/docs/user_guide/index.html — full user guide68- https://pandas.pydata.org/docs/getting_started/intro_tutorials/index.html — getting-started tutorials69- https://pandas.pydata.org/docs/reference/index.html — API reference7071## Related skills72- ../numpy — array engine underlying pandas73- ../scikit-learn — consumes DataFrames for ML74- ../jupyter — interactive notebooks for data exploration