Glossary
107 terms from pandas Beyond the Basics, in plain words, each with the chapter that teaches it.
A
- Anti-join
- A join that keeps only the rows of one table that have no match in the other. Sam used it to find the Kettle & Crane cafés with no orders since July 1.
- Apache Arrow
- A fast way of storing table columns in memory. pandas 3 uses it, through pyarrow, to store text columns, which saves memory and speeds up `.str` methods.
- apply
- The most general tool: it runs your own function once per value or once per group and glues the results together. It runs Python code each time, so prefer `agg` or `transform` when they can do the job.
- assert
- A Python statement that checks a condition and stops the program with an `AssertionError` and your message if the condition is false. It makes your assumptions about the data explicit.
- assign
- A DataFrame method that adds or replaces columns and returns a new DataFrame, so it can sit in the middle of a method chain. Give it a lambda so it can use the table as it is at that point in the chain.
- Average order value
- Total sales divided by the number of orders. In the review it is the average online order, counted by distinct orders rather than order lines.
- Axes
- In matplotlib, one panel of a chart with its own x and y axes. A Figure holds one or more Axes, and you format each chart through its Axes.
B
C
- Capture group
- The part of a regular expression inside `( )` that `.str.extract` returns. A named group `(?P<name>...)` makes the name the column name.
- Category dtype
- A column type whose values come from a fixed list of labels. pandas stores each value as a small code plus the list once, which saves memory and lets you give the labels an order.
- Check function
- A function that tests a table against several rules and returns a list of every problem, with the order numbers affected. Unlike `assert`, it doesn't stop at the first failure.
- chunksize
- An argument to `read_csv` that reads a big file a piece at a time instead of all at once. You summarize each chunk and combine the summaries.
- Code
- The small whole number pandas stores in place of each value in a category column. `.cat.codes` shows these numbers.
- Cohort
- A group of customers who started at the same time. In the review it means all online customers whose first order was in the same month.
- Conversion rate
- The share of web visits that end in an order. At Kettle & Crane the newsletter converted at 4.82%, much better than Instagram.
- crosstab
- A shortcut that counts how many rows have each combination of two values, given as two Series. `normalize=` turns the counts into shares.
- CSV
- A plain-text file format for tables, with one row per line and values separated by commas. It is slow to read, big on disk, and forgets column dtypes.
- cumcount
- A groupby method that numbers the rows in each group 0, 1, 2… in their current order. Adding 1 gives each customer's first, second, third order.
- cumsum
- `cumsum()` adds up as it goes, so each value is the total so far (a running total). It is the basis of year-to-date figures.
D
- DatetimeIndex
- An index made of dates and times. With one, `.loc` accepts partial dates like "2026-09", and tools such as `resample` and time-window `rolling` work.
- Daylight saving time
- The practice of moving clocks forward in spring and back in autumn. It is why Portland is 7 or 8 hours behind UTC, and why some local times don't exist or are repeated.
- diff
- Subtracts the previous row's value from each value. After `groupby` it subtracts within each group only, such as the gap between a customer's orders.
- drop_duplicates
- Keeps one row for each distinct value (or combination) in the columns you name. It turns order lines into one row per order, or customer rows into one per customer.
- dtype
- The type of values stored in a column, such as `float64`, `int8`, `category` or `datetime64`. Choosing the right dtype saves memory and keeps values correct.
E
F
- f-string format specifiers
- Codes after a colon inside an f-string that control how a value prints. For example `:,.0f` gives whole numbers with commas, `:+.1f` always shows a sign, and `:.0%` multiplies by 100 and adds a percent sign.
- Figure
- The whole matplotlib image, which holds one or more Axes. You save it with `fig.savefig` and close it to free memory.
- fill_value
- An argument that puts a chosen value, usually 0, in cells with no data in `pivot_table` or `unstack`. Use it only when an empty cell truly means zero.
- filter
- A groupby method that calls your function once per group and keeps every row of the groups where it returns True. Priya could use it to keep customers with three or more orders.
- Frequency
- A short code for the length of a time slot, such as "D" for day, "W" for week or "ME" for month-end. pandas 3 renamed some codes, so "M" became "ME" in `resample`.
G
- Gross margin
- The share of sales left after paying for the goods. Kettle & Crane's was 40.9% on coffee and 62.1% on gifts.
- Grouper
- An object that lets you group by a time slot inside `groupby`, together with other columns. It acts like a `resample` inside a `groupby`.
H
- Heatmap
- A grid of cells colored by their values so patterns stand out. A retention heatmap, for example, shows each customer cohort against months since its first order.
I
- indicator=
- A `merge` option that adds a column labeling each row `both`, `left_only` or `right_only`. It shows which rows found a match.
- int8
- Small whole-number dtypes that use 1, 2 or 4 bytes per value instead of 8. `int8` holds -128 to 127, so check the column's `.max()` first or large values are silently stored wrongly.
- iterrows
- A method that loops over a DataFrame's rows, giving each row's label and the row as a Series. It is very slow, so treat using it as a warning sign.
J
- Join
- `df.join(other)` is a shortcut for a left merge on the index. The review uses it to add the online and wholesale columns to the monthly rows.
K
- Key
- The columns that together identify one row. In the orders table, `order_id` plus `sku` is the key, and checking it is unique catches duplicate lines.
L
- Lambda
- A short function without a name, written in place: `lambda x: x * 2`. It suits one-off functions passed to methods like `filter`, `apply` and `assign`.
- Landing page
- The web address where a web visit started. It may carry UTM tags saying where the visitor came from.
- Level
- One layer of a MultiIndex. Grouping by month and channel gives an index with two levels.
- Long data
- A table with one row per observation and one column per kind of value, also called tidy. Most pandas tools expect it.
M
- Margins
- The total row and column that `pivot_table(margins=True)` adds at the edges of a pivot table. `margins_name=` labels them.
- matplotlib
- A Python library for drawing charts, which pandas uses for its `.plot()` methods. It can draw line charts such as a monthly sales trend and grid charts such as a heatmap, and save them as image files.
- melt
- Turns a wide table into a long one by moving column names into the values of one column. `id_vars=` columns stay as they are, and `var_name=` and `value_name=` name the two new columns.
- memory_usage
- A method giving each column's size in bytes. `deep=True` counts the text itself, not just pointers to it.
- merge_asof
- A join that matches each row to the nearest earlier (or later) row of another table instead of an exact key. It found which wholesale list price was in force at each order time; both tables must be sorted.
- Method chain
- Writing an analysis as one expression where each method works on the result of the one before, usually in parentheses with one step per line.
- Module
- A `.py` file you can import. `kc.py` is a module holding Kettle & Crane's loading code, so `from kc import load_orders` works in any script in the folder.
- Month over month
- A comparison of a month with the month before it, such as September dipping 2.1% from August.
- Moving average
- The average of a window that slides along the data, used to smooth noise. A 7-day moving average covers a full week of weekday patterns.
- MultiIndex
- An index with two or more levels, where each row is labeled by a tuple. Grouping by several columns produces one.
N
- Naive time
- A time with no time zone attached. After `tz_localize(None)` the order times are naive local Portland times.
- NaN
- The marker for a missing value in pandas. It forces integer columns to become `float64` unless you use a nullable type such as `Int64`.
- np.select
- A NumPy function that takes a list of conditions and a matching list of results, giving each row the result of the first condition it meets, or `default=` if none. List the most specific condition first.
- np.where
- A NumPy function that gives one value where a condition is true and another where it is false, for every row at once. It labels rows by a single rule.
- Nullable integer
- The `Int64` dtype, with a capital I: whole numbers that can also be missing, shown as `<NA>`. It keeps `order_id` as whole numbers despite the gaps.
- NumPy
- The Python library of fast array calculations that pandas is built on. It is imported as `np` and supplies `np.where`, `np.select`, `np.inf` and `np.nan`.
- nunique
- Counts the different values in a column or group. Use it to count orders rather than order lines, since an order has one line per SKU.
O
- observed=False
- A groupby option that makes a category column list every category, including empty ones with a count of 0. In pandas 3 the default shows only categories that occur.
- Ordered category
- A category column whose labels have an order, so sorting, grouping, charts and comparisons like `>= "Saturday"` follow it. Set it with `pd.CategoricalDtype(list, ordered=True)`.
P
- Parquet
- A compressed file format built for tables that stores each column in binary form together with its dtype. It is smaller and faster to read than CSV and needs pyarrow.
- pct_change
- The change from the previous row as a fraction of the previous value. `pct_change(12)` on monthly data compares with the same month last year.
- pd.cut
- Sorts numbers into bins whose edges you choose, optionally with labels. By default each bin includes its right edge; `right=False` includes the left edge instead.
- pd.qcut
- Sorts numbers into bins chosen so each holds about the same number of values, such as quartiles. Use it for "top 10%" questions.
- Period
- A span of time such as September 2026, rather than a single moment. Periods sort in time order, print neatly and support arithmetic like `p - 12`; an index of them is a PeriodIndex.
- pip
- Python's tool for installing packages such as pandas and pyarrow from the command line.
- pipe
- A method that puts your own function into a method chain: `df.pipe(f, x)` means `f(df, x)` but reads in order. It is used for reusable steps like `add_quarter` and checks like `require_clean`.
- pivot
- Reshapes long data to wide by moving values into place without calculating anything, so each row and column pair may appear only once. It fails with a duplicate-entries error on repeated data.
- Pivot table
- A grid summary with one row per value of one column, one column per value of another, and a calculation (`aggfunc=`) in each cell. It is like a spreadsheet pivot table.
- pyarrow
- The Python library for Apache Arrow. With it installed, pandas 3 stores text columns compactly and can read and write Parquet files.
Q
- Quartile
- One of four equal-sized groups of sorted values. The top quartile of online customers by spend brought in 52% of online sales.
- query
- A DataFrame method that filters rows with a text condition using column names directly. `@name` uses an outside Python variable, and backticks quote odd column names.
R
- Raw string
- A Python string with `r` before the quote, which leaves backslashes as typed. Regex patterns are written this way so `\d` reaches the regex engine unchanged.
- Reconcile totals
- Checking that a summary adds up to the data it came from, such as comparing a pivot table's grand total with the sum of the original column. Round floats to cents before comparing.
- Regular expression (regex)
- A small pattern language for describing text, built into Python's `re` module and many pandas `.str` methods. For example `\d+` means one or more digits.
- resample
- `groupby` for time: it groups a DatetimeIndex into slots such as days, weeks or months and applies a calculation. It includes empty slots, which `sum` gives 0.
- Retention
- The share of a cohort that is still active some time later. In the review, it is the share of each month's new online customers who order again 1, 2, 3… months on.
- Rolling window
- A fixed number of rows, or a length of time like "7D", sliding down the data one row at a time. `min_periods=` lets the result start before the window is full.
S
- set_index / sort_index
- `set_index` makes a column, such as the order time, the index; `sort_index` puts the rows in index order. Time tools like `resample` and time-window `rolling` need a sorted DatetimeIndex.
- shift
- Moves every value down by a number of rows so each row sees an earlier one. The first rows become NaN, and it counts rows, not months.
- size vs count
- After `groupby`, `.size()` counts all rows per group, missing values included, while `.count()` counts only non-missing values. Counting a column of order numbers with `count` therefore counts orders.
- SKU
- The short code that identifies a product, such as HE-5 for House Espresso 5 lb. It is the key for joining orders to products.
- stack
- Moves column labels into the innermost index level, making a table longer. It is the reverse of `unstack`.
- Standard deviation
- A measure of how much values typically vary around their average. A typical September day brought in $263, give or take about $122.
- str.replace
- A `.str` method that rewrites text. With `regex=True` the first argument is a pattern, so `r"\?.*$"` deletes everything from the `?` to the end.
- str.split
- A `.str` method that splits each text value at a separator. `expand=True` puts the pieces in separate columns and `n=1` splits only at the first separator.
T
- Time zone aware
- Times that carry their zone, shown in the dtype (such as `datetime64[us, UTC]`) and as an offset like `+00:00`. Text ending in `Z` loads this way.
- Timedelta
- A length of time, such as 7 days, produced by subtracting two times. `.dt.days` keeps the whole days.
- Timestamp
- A single date and time value in pandas, such as `pd.Timestamp("2026-09-30 23:59")`. It is a moment, unlike a Period, which is a span.
- tolerance
- Options of `merge_asof`: `direction=` chooses backward, forward or nearest matching, and `tolerance=` refuses matches farther away than a given gap.
- transform
- A groupby method that calculates a group result but returns it lined up with the original rows, so every row gets its own group's value. It is how you compare a row with its group.
- Transpose
- Swaps rows and columns, written `.T`. The review uses it so 12 measures fit on screen with one column per month.
- try/except
- Python's way of catching an error so the program can handle or print it instead of stopping. For example, wrapping a merge in `try` and catching `pd.errors.MergeError` in `except` lets you print the error message.
- tz_convert
- `tz_convert` changes a time-zone-aware time to another zone without changing the moment. `tz_localize` tells pandas which zone naive times are in, or with `None` removes the zone.
U
- unstack
- Moves the innermost index level (or a named one) into the columns, turning a long Series wide. `fill_value=0` fills missing combinations.
- UTC
- Coordinated Universal Time, the world's reference clock, with no daylight saving. A trailing `Z` in a time such as `2025-01-01T21:02:38Z` means UTC.
- UTM parameters
- Tags after the `?` in a web address that say where a visitor came from: `utm_source` (the site), `utm_medium` (kind of link, such as cpc for paid ads) and `utm_campaign`.
V
- validate=
- A `merge` option stating the expected shape (one_to_one, many_to_one, one_to_many); pandas raises a `MergeError` if the data disagrees. It prevents the many-to-many trap, where repeated keys on both sides duplicate rows and inflate totals.
- Vectorized operation
- An operation applied to a whole column at once by compiled NumPy code, such as `sessions["pages"] == 1`. It is far faster than `iterrows` or `apply`.
- virtual environment
- A project-specific folder of installed Python packages, created with `python3 -m venv .venv` and activated before `pip install`. It keeps projects' packages separate.
W
- Wide data
- A table with one kind of value spread across several columns, such as Sam's targets with a column per month. You can't filter or merge on the month because it is hidden in column names.
X
- xs
- A method that picks a label from a chosen level of a MultiIndex, such as `actual.xs("online", level="channel")`.
Y
- Year-over-year
- A comparison with the same period a year earlier, which removes seasonal swings like the December gift peak. On monthly data it is `pct_change(12)`.
- Year-to-date
- A running total that restarts each January. Group by year before `cumsum` to get it.