<aside> 💡
Pandas 3.0 (released January 2026) made copy-on-write the default and turned the old chained-assignment warning into a hard error. The patterns below use .loc[], which stays safe either way.
</aside>
| Function | What it does |
|---|---|
len() |
Returns the number of items in a list, string or other collection |
range() |
Generates a sequence of numbers, most often used in a for loop |
enumerate() |
Loops over a collection while also giving you the index |
zip() |
Pairs up items from two or more collections |
sorted() |
Returns a sorted copy of a collection (sorted(x, reverse=True) for descending) |
sum() |
Adds up a collection of numbers |
map() |
Applies a function to every item in a collection |
filter() |
Keeps only the items that pass a condition |
[x for x in y if ...] |
List comprehension: builds a list in one line |
type() |
Shows the type of a value |
isinstance() |
Checks whether a value is a particular type |
| Method | What it does |
|---|---|
.split() |
Breaks a string into a list, on whitespace or a given separator |
.join() |
Joins a list of strings into one, using the string it's called on as the separator |
.strip() |
Removes leading and trailing whitespace |
.replace() |
Swaps one substring for another |
f"{variable}" |
f-string: embeds a variable directly inside a string |
| Method | What it does |
|---|---|
pd.read_csv() |
Loads a CSV file into a DataFrame (read_parquet, read_json also exist) |
.head() / .info() / .describe() |
Previews the data, its structure, and summary stats |
.loc[] |
Selects rows and columns by label, and the safe way to assign values |
.groupby() |
Groups rows to run an aggregate function per group |
.merge() |
Joins two DataFrames together, similar to a SQL join |
.pivot_table() |
Reshapes data into a summary table |
.fillna() / .dropna() |
Fills or removes missing values |
.apply() |
Runs a function across a column or row |