Python flash cards: Journeyman level
168 Python terms at the Journeyman level, as flash cards.
Updated
Terms in this deck
- __init__ (Constructor)
- Runs automatically when an object is created and sets up its starting data.
- __init__.py
- A file that marks a folder as a Python package.
- __str__ and __repr__
- Control how an object looks when printed (__str__) and when debugging (__repr__).
- agg()
- A pandas method that works out several summaries for each group at once, such as a sum, a mean and a count, and hands them back as one table.
- annotate()
- A matplotlib method that writes a note on a chart with an arrow pointing at one value: xy is the point, xytext where the words sit.
- apply()
- A pandas method that runs a function, or a lambda, on every value of a column, one at a time.
- argparse
- Python's standard module that reads a script's command-line arguments into positional arguments, options and flags, checks them and writes a --help page.
- assert
- Checks that something is true, and stops with an error if not.
- astype()
- A pandas method that turns a column into another type, such as text into whole numbers, and stops if any value can't be converted.
- Attribute
- A piece of data that belongs to an object, reached with a dot.
- autoreload
- A notebook kernel's tool that reloads a changed module before each cell runs, turned on with %load_ext autoreload and %autoreload 2.
- Axes
- In matplotlib, one chart on a Figure: the area with the data and the two axes it's measured against.
- bar_label()
- The matplotlib Axes method that writes each bar's value at its end, given the bars ax.bar or ax.barh handed back.
- between()
- A pandas method that answers True for each value from a low number to a high one, both ends included, and False for a value outside it or a missing one.
- Boolean Mask
- A column of True and False answers, one per row, made by a comparison; df[mask] keeps the rows where it's True.
- Built-in Exceptions
- The error types Python already has, like ValueError and KeyError.
- capsys
- A fixture pytest has built in that catches what code prints while a test runs; capsys.readouterr().out is the printed text.
- Chained Comparison
- Several comparisons in one go, like 18 <= age < 65.
- Class
- A blueprint for making objects that bundle data with actions.
- Class Attribute
- Data shared by every object made from a class.
- Classification Report
- scikit-learn's printed table of precision, recall, F1 score and support for every class, with accuracy and averages below.
- Colorblind-Friendly Palette
- A set of colors chosen to stay different for most color-blind readers, such as matplotlib's tableau-colorblind10 style.
- concat()
- pd.concat stacks tables that share their columns, one under the other; ignore_index=True numbers the stacked rows from 0 again.
- Conditional Expression
- Picks one of two values in one line: this if condition else that.
- conftest.py
- A file pytest reads before it runs the tests in its folder, for set-up every test there shares, such as choosing matplotlib's Agg backend.
- Correlation
- How closely two columns move together, as a number from -1 to 1; near 0 means no straight-line pattern. It doesn't show that one causes the other.
- crosstab()
- pd.crosstab counts how often each combination of two columns' values happens; normalize="index" turns each row into shares.
- csv Module
- Python's built-in module for reading and writing CSV files: csv.reader and csv.DictReader read the rows, csv.writer and csv.DictWriter write them.
- Custom Exception
- Your own error type, named for exactly what went wrong.
- cut()
- pd.cut sorts numbers into labeled bands, such as budget, mid and premium, from a list of edges.
- DataFrame
- pandas' table: named columns, and a label for each row called its index, like one sheet of a spreadsheet inside a program.
- DataFrame.plot()
- The pandas method that draws a DataFrame or Series as a chart with matplotlib (kind= picks which) and hands back the Axes it drew on.
- Date Format Code
- A code such as %m (month), %d (day) or %Y (four-digit year) that describes one piece of how a date is written, as in "%m/%d/%Y".
- datetime Module
- A standard module for working with dates and times.
- Debugger (pdb)
- A tool that pauses your program so you can inspect it line by line.
- Deep Copy
- A copy of a collection and everything inside it, fully separate.
- describe()
- A pandas method that sums up each number column: count, mean, standard deviation, min, the quartiles and max.
- Dictionary Comprehension
- Builds a new dictionary in a single line.
- drop_duplicates()
- A pandas method that hands back the table without its repeated rows; subset names the columns to compare and keep which copy stays.
- dropna()
- A pandas method that hands back the table without the rows that have missing values, or only those missing the columns named in subset.
- dt accessor
- Read "dot d t": the date tools of a pandas date column, such as year, month, day_name() and hour, each working on every row at once.
- dtype
- Short for data type: the kind of value every row of a pandas column holds, such as int64, float64 or str.
- DummyClassifier
- A scikit-learn model that ignores the features and guesses by a simple rule, the most common class by default, to give a baseline.
- DummyRegressor
- A scikit-learn model that ignores the features and always guesses one number, the training average by default, to give a baseline.
- Dunder Method
- A method with double underscores, like __len__, that Python calls for you.
- duplicated()
- A pandas method that answers True for each row that repeats a row above it, on every column or on a subset.
- Encapsulation
- Keeping an object's data behind its methods so it's changed the safe way.
- Environment Variable
- A setting stored outside your code, the safe place for passwords and keys.
- Estimator
- scikit-learn's word for any object that learns from data with a fit method, such as LinearRegression or StandardScaler.
- Exception
- Python's way of reporting an error while a program runs.
- Exception Chaining (raise … from)
- Raising a clearer error while keeping the original attached (raise ... from).
- Exploratory Data Analysis
- Looking around a new dataset to learn what's in it before answering a question: its size, columns, gaps and odd values. Often shortened to EDA.
- Fairlearn
- A Python package for checking and improving a model's fairness, with MetricFrame for scores by group and gap measures such as demographic parity.
- Figure
- In matplotlib, the whole image that gets saved, like a sheet of paper with one or more charts drawn on it.
- fillna()
- A pandas method that puts a stand-in, such as "Unknown" or a median, into every missing value.
- filter()
- Keeps only the items that pass a test.
- finally
- Runs after try/except no matter what, for clean-up.
- fit_predict()
- The scikit-learn method that fits a model and hands back its answers for the same rows in one call, as KMeans uses it.
- glob()
- A pathlib method that finds the files in a folder whose names match a pattern, where * stands for any text, such as week-*.csv.
- groupby()
- The pandas method that sorts a table's rows into groups by a column's value, so each group can be totaled or averaged on its own.
- Higher-Order Function
- A function that takes or returns another function.
- Identity vs Equality (is vs ==)
- == checks equal values; is checks the very same object.
- iloc
- Read "i loc": pandas' way to pick rows and columns by position, counting from 0; a slice stops before its end.
- Imputation
- Filling in missing values with stand-ins worked out from the data, such as a median; the statistics-class name for it.
- Index
- The labels of a pandas Series or DataFrame, one for each value or row, used to find them; without labels of your own, they count from 0.
- Inheritance
- A new class starts with everything from another class, then adds or changes things.
- Instance
- One object made from a class, with its own data.
- ipykernel
- The package that lets VS Code run a notebook's cells with a virtual environment's Python; it goes in each project's requirements.txt.
- isin()
- A pandas method that answers True for each value found in a list, such as the categories boots or jackets.
- Iterable
- Anything you can loop over with for.
- joblib
- A Python package whose dump() and load() save a trained model to a file and read it back; scikit-learn's usual way to save models.
- json Module
- Turns Python data into JSON text and back.
- KMeans
- scikit-learn's k-means: KMeans(n_clusters=3) learns the centers with fit(), and labels_ says which cluster each row is in.
- Lambda Function
- A small, nameless one-line function.
- List Comprehension
- Builds a new list from another collection in a single line.
- Literal Type
- A type hint from Python's typing module that lists the only values allowed, such as Literal["dog", "cat", "rabbit"], matched exactly.
- loc
- pandas' way to pick rows and columns by their labels, as df.loc[rows, columns]; a label slice includes its end.
- logging Module
- A standard module that records what your program does, with levels.
- Magic Command
- A line that starts with %, such as %autoreload 2: an instruction to a notebook's kernel, not Python, so it works only in a notebook.
- Main Guard (if __name__ == "__main__")
- Runs code only when the file is run directly, not when imported.
- make_pipeline()
- scikit-learn's shortcut that builds a Pipeline from the steps alone, naming each one after its class, such as standardscaler.
- map()
- Runs a function on every item in a collection.
- matplotlib
- The Python package most charts are drawn with: a Figure holds one or more Axes, and each Axes is one chart.
- merge()
- A pandas method that joins two tables side by side by a key column they share, the job a spreadsheet's VLOOKUP does; how= says which rows that don't match are kept.
- Method
- A function that belongs to a class, called on an object with a dot.
- Method Chaining
- Writing several pandas steps as one expression, one method per line, each working on the table the step before it returned.
- Method Overriding
- A child class writing its own version of an inherited method.
- Namespace
- A set of names kept separate so they do not clash.
- NaT
- Read "not a time": pandas' mark for a missing date or length of time.
- nbconvert
- The Jupyter tool that converts a notebook to other formats: jupyter nbconvert --to html story.ipynb writes a web page anyone can open.
- nlargest()
- A pandas method that gives the rows with the largest values in a column, such as the three most-reviewed products.
- np.where()
- A NumPy function that gives each row one of two values: the first where a condition is True, the second where it's False.
- NumPy
- The Python library for fast math on arrays of numbers; pandas keeps every column's values in a NumPy array.
- NumPy Array
- NumPy's container (ndarray): many values of one type, packed side by side, that does math on all of them at once.
- OneHotEncoder
- scikit-learn's tool for one-hot encoding: it learns each column's categories with fit() and makes a 0-or-1 column for each.
- openpyxl
- The Python library that reads and writes Excel .xlsx files; pandas uses it behind read_excel, so it must be installed.
- OrdinalEncoder
- scikit-learn's tool that turns each category into a number, 0, 1, 2 and so on, in an order you can set, such as small, medium, large.
- Package
- A folder of related modules you can import from.
- pandas
- The Python package for tables of data: it reads a CSV file into a DataFrame, then sorts, filters, totals and charts it in a line or two.
- pathlib
- Python's standard module for file and folder paths: a Path holds an address in parts, joins them with / and reads a file's name, stem, suffix and parent.
- Pattern Matching (match/case)
- match/case: compares a value against patterns and runs the first that fits.
- PEP 8
- Python's official style guide for how code should look.
- pickle
- Python's built-in module that turns objects, a trained model included, into bytes and back; never load a pickle you don't trust.
- pip
- The tool that installs Python packages from the internet.
- pip-audit
- A command that checks a project's packages against a public list of known security holes, and names the version that fixes each.
- Pipeline
- A scikit-learn object that chains preparing steps and a model into one, so fit() and predict() run every step in order.
- pivot_table()
- The pandas method that builds a pivot table from index, columns, values and aggfunc, with fill_value for empty squares and margins for totals.
- plt.close()
- Closes a matplotlib figure so pyplot stops keeping it in memory; a test calls plt.close(fig) when it has read the chart.
- Polymorphism
- Different objects answering the same method call in their own way.
- predict_proba()
- The scikit-learn method that gives, for each row, the classifier's probability for every class, in the order of classes_.
- Private Attribute (_name)
- An attribute starting with _ that others should leave alone.
- pytest
- The most popular Python testing tool: test functions with plain assert.
- pytest.raises
- pytest's way to make sure code raises an error: a test passes only when the code inside with pytest.raises(...) raises that error.
- Quartile
- One of the values that cut sorted data into quarters: 25% of the values are at or below the first, half at or below the second (the median).
- raise
- Triggers an exception on purpose.
- raise_for_status()
- A requests response method that raises an HTTPError when the status code is from 400 to 599, and does nothing otherwise.
- Random Seed
- The starting number for Python's random numbers: the same seed gives the same "random" results on every run, which is what tests need.
- read_excel()
- pd.read_excel loads a sheet of an Excel workbook into a DataFrame; sheet_name picks the sheet and skiprows steps over title rows.
- read_json()
- pd.read_json loads JSON into a DataFrame, a row for each record; lines=True reads JSON Lines.
- Regular Expression
- A pattern for finding or checking text.
- rename()
- A pandas method that hands back a table with new column names, given a dictionary of old name to new name in columns=.
- requests
- The Python package most programs use to call web APIs: requests.get sends a request and gives back a response to read.
- requirements.txt
- A file listing the packages a project needs.
- reset_index()
- A pandas method that numbers a table's rows 0, 1, 2 again, moving the old row labels, such as a groupby's groups, into a column, or dropping them with drop=True.
- Ruff
- A fast Python linter and formatter in one tool: ruff check finds likely mistakes such as unused imports, and ruff format lays out every file the same way.
- self
- The object a method is working on, passed in automatically.
- Series
- One column of a pandas table, with the table's row labels; its methods, such as sum() and max(), work on the whole column at once.
- Series.map()
- A pandas method that, given a dictionary, gives each value the one the dictionary pairs with it, and NaN for a value it doesn't name.
- Series.replace()
- A pandas method that, given a dictionary, changes only the values the dictionary names and leaves every other value as it was.
- Set Comprehension
- Builds a new set from another collection in a single line, written in curly braces with one expression.
- Set Operations
- Combining sets: | both, & shared, - only in the first.
- set_index()
- A pandas method that makes a column, such as a product code, the table's row labels, so loc can find rows by it.
- set_ylim()
- A matplotlib method that sets where a chart's y-axis starts and ends; set_ylim(bottom=0) starts it at zero.
- Shallow Copy
- A new collection that still shares the items inside it with the original.
- Shared Axis
- One axis scale used by charts side by side, so their bars and lines compare by eye; plt.subplots(sharey=True) makes one.
- shutil
- Python's standard module for copying and moving files and folders, such as shutil.copy2 and shutil.move; read "shell utilities".
- SimpleImputer
- scikit-learn's tool that fills missing values with one value per column learned in fit(), such as the column's median.
- Split-Apply-Combine
- What a grouping does in three steps: split the rows into groups, work out one number for each group, and combine the answers into one result.
- sqlite3.IntegrityError
- The exception Python's sqlite3 module raises when a change would break a rule of the data, such as a repeated value in a UNIQUE column.
- Standard Deviation
- How far values usually sit from their average; describe() shows it as std.
- StandardScaler
- scikit-learn's tool that standardizes features: fit() learns each column's mean and standard deviation, transform() rescales with them.
- Step Into
- The debugger's command (F11 in VS Code) that goes inside the function the highlighted line calls and pauses on its first line.
- Step Over
- The debugger's command (F10 in VS Code) that runs the highlighted line, a function call included, and pauses on the next one.
- str accessor
- Read "dot s t r": the string tools of a pandas text column, such as strip, lower and contains, each working on every value at once.
- str.replace()
- A pandas text tool that swaps one piece of text for another in every value of a column, such as taking " lbs" off weights.
- str.split()
- A pandas text tool that cuts each value at a separator, a space by default; expand=True puts the pieces in columns and n limits the cuts.
- subplots()
- plt.subplots makes a Figure and its Axes in one call: one chart, or a grid such as 2 by 2 picked as axs[row, column].
- super()
- Calls a method from the parent class, usually to add to it.
- sys.argv
- The list of words a Python program was started with: the script's name first, then each word typed after it, all as strings.
- Test Fixture
- Shared setup, like sample data, that tests can use.
- Third-Party Library
- Code written by others that you install with pip.
- Tidy Data
- The textbook name for a table where each row is one observation and each column is one kind of value.
- Timedelta
- pandas' type for a length of time, such as 60 days 16 hours or 27 minutes 15 seconds; subtracting two dates gives one.
- Timestamp
- pandas' type for one date and time, such as 2026-08-03 07:40; a datetime64 column holds one per row.
- tmp_path
- A fixture pytest has built in: a new, empty folder for one test, where it can write files without touching the project.
- to_datetime()
- pd.to_datetime turns text into dates; format= says how they were written, and errors="coerce" makes each date it can't read NaT.
- to_excel()
- A pandas method that saves a table as an Excel workbook (.xlsx), using the openpyxl package.
- to_html()
- A pandas method that gives back a table as HTML text, ready to put in a web page; index=False leaves out the row numbers.
- to_numeric()
- pd.to_numeric turns a column of text into numbers; with errors="coerce", each value it can't read becomes NaN.
- to_period()
- A .dt method that turns each date into the period it falls in, such as its month, so rows can be grouped by month.
- to_timedelta()
- pd.to_timedelta turns text such as "0:27:15" (hours:minutes:seconds) into a Timedelta, a length of time.
- total_seconds()
- A Timedelta method (.dt.total_seconds() on a column) that gives the length of time as a number of seconds.
- try and except
- try runs code that might fail; except catches the error instead of crashing.
- Unit Test (unittest)
- Code that checks one function gives the right answer.
- Vectorized Operation
- Math done on a whole array or column at once, with no loop of your own, such as prices * 0.9.
- Version Pinning
- Writing a package's exact version in requirements.txt, such as pytest==9.2.0, so every computer installs the same one.
- Virtual Environment
- A project's own private set of installed packages.
- Walrus Operator
- The := operator: saves a value and uses it in the same line.