Python vocabulary: Freelancer level

68 Python terms at the Freelancer level, each with a short definition and a link to its full page.

Updated

Study these as flash cards

__iter__ and __next__
Methods that make your own class work in a for loop.
Abstract Base Class (abc)
A class you cannot use directly; it lists methods every child must write.
Agg Backend
The matplotlib backend that draws charts in memory with no window, so chart tests run on a computer with no screen.
assert_frame_equal()
pd.testing.assert_frame_equal compares two DataFrames in a test: column names, order, values and types, and says which column differs when they don't match.
assign()
A pandas method that hands back a new table with a column added or replaced, often with a lambda that gets the table at that step.
async and await
async def makes a pausable function; await is where it waits without blocking.
asyncio
The standard module that runs async code, doing many waits at once.
category dtype
A pandas column type for values from a short, fixed list, such as shirt sizes, stored once and optionally kept in an order of your own.
Class Method (@classmethod)
A method that belongs to the class, often another way to create objects.
Closure
An inner function that remembers the variables around it.
ColumnTransformer
A scikit-learn tool that prepares different columns in different ways, such as scaling the numbers and encoding the categories, then joins them.
Context Manager
Sets something up at the start of a with block and cleans up at the end.
contextlib
A standard module for writing your own context managers easily.
Copy-on-Write
How pandas 3 handles copies: a copy shares the data until one of them changes, so copying is cheap and a chained assignment changes nothing.
Coroutine
What an async def function returns: a task that can pause and resume.
Counter
Counts how many times each item appears.
Dataclass
A class for holding data; @dataclass writes __init__ and more for you.
Decorator
Wraps extra behavior around a function, applied with @name above it.
defaultdict
A dictionary that fills in a starting value for a new key automatically.
deque
A list built for quickly adding and removing at both ends.
Duck Typing
Python cares what an object can do, not what class it is.
Enum
A fixed set of named choices, like order statuses.
Generator
A function that hands out values one at a time with yield.
Generator Expression
Like a list comprehension in round brackets, producing values one at a time.
Generic Type (TypeVar)
Lets code work with any type while keeping in and out types linked.
get_feature_names_out()
The scikit-learn method that names each column a fitted preparing step hands back, such as species_cat and species_dog.
get_params()
The scikit-learn method that hands back a model's settings as a dictionary of names and values, such as max_depth: 3.
GridSearchCV
scikit-learn's grid search: it cross-validates every combination of the settings you list and refits the best on all the training rows.
GroupShuffleSplit
A scikit-learn splitter that keeps all the rows of one group, such as one customer, on the same side of the train-test split.
httpx
A Python package for web requests with the same shape as requests (get, status_code, json(), raise_for_status()), which can also send many requests at once.
Iterator
Gives out items one at a time with next() and remembers where it is.
itertools
A standard module of ready-made looping tools.
Job Queue
A separate program that keeps background work in a store of its own, runs it in workers apart from the web server and retries it, such as Celery or RQ.
json_normalize()
pd.json_normalize turns nested JSON data into a flat table: record_path names the list whose items become rows, meta the fields copied onto each.
Logging Levels
How serious a log message is, from DEBUG up to CRITICAL.
make_column_transformer()
scikit-learn's shortcut that builds a ColumnTransformer from (tool, columns) pairs, naming each part after its tool's class.
melt()
A pandas method that turns a wide table into a long one: the columns named in id_vars stay, and every other column becomes rows of a name and a value.
Memoization (lru_cache)
Saving a function's answers so repeat calls return instantly.
Mocking (unittest.mock)
Swapping a real part of the program for a fake one during a test.
MultiIndex
Row labels on two or more levels, such as a neighborhood and a pizza size, which pandas makes when it groups by two columns.
Multiprocessing
Runs work in separate processes so heavy calculations run in parallel.
Mutable Default Argument
A default like [] is shared by every call. Use None and make a new one inside.
mypy
A tool that checks your type hints and warns about type mistakes.
Named Aggregation
Writing agg as name=(column, summary), so each summary becomes a column with the name you chose, from the column you chose.
Named Tuple
A tuple whose items also have names.
nonlocal
Lets an inner function change a variable from the function around it.
Optional (typing)
In a type hint: the value can be that type or None.
Parametrized Test
One test run with several sets of inputs and expected answers.
Partial Function (functools.partial)
A copy of a function with some arguments already filled in.
pipe()
A pandas method that calls your own function with the table, so a step you wrote fits into a method chain.
pivot()
A pandas method that turns a long table into a wide one from index, columns and values, and stops with an error when two rows would fill one cell.
Property (@property)
Lets a method be used like an attribute, with no brackets.
Protocol
Describes what an object must be able to do, whatever class it is.
pyproject.toml
One file describing a Python project: name, version, packages it needs.
Race Condition
A bug where the result depends on which thread gets there first.
resample()
A pandas method that cuts a date index into periods, such as weeks or months, and summarizes each one, keeping the periods with no rows.
set_params()
The scikit-learn method that changes a model's settings by name, such as tree.set_params(max_depth=5), and hands back the model.
SQLAlchemy
Python's most used ORM and database toolkit: tables described as classes, and queries built in Python that it turns into SQL.
Static Method (@staticmethod)
A plain function kept inside a class; it uses neither self nor the class.
str.extract()
A pandas text tool that keeps the part of each value a regular expression's parentheses match, such as the digits in "about 30", and NaN where nothing matches.
Styler
What df.style makes: the same table drawn for people, with a format for each column, such as $20.00 or 97.2%, and the index hidden if you choose.
Thread (threading)
Lets part of a program run alongside the rest, handy while waiting on things.
transform()
A groupby method that works out a summary for each group and hands it back on every row of that group, lined up with the table.
Type Hint
A note saying what type a value should be, used by editors and tools.
Union Type
A type hint saying a value can be one of several types, like int | str.
Unpacking Operator (* and **)
In a call, * spreads a list into arguments and ** spreads a dictionary.
Wheel (package build)
A ready-to-install Python package file (.whl).
yield
Hands back one value from a generator and pauses until the next one is needed.

Every Python term, by level