Pandas

Sefism.

A to Z

Glossary

Every concept in this sheet, plus the smaller terms it uses. Select a concept to open its card.

C
Copy-on-write
Since pandas 3.0 every selection or method result behaves as a new object: changing it never changes the original. pandas only copies data when you actually modify it.
D
DataFrame and Series
A Series is one labelled column of values with a single dtype.
E
Excel, SQL, JSON and Parquet
pandas has a reader for each common source: read_excel for workbooks, read_sql for a database query, read_json for JSON and read_parquet for columnar Parquet files.
F
First look at a dataset
head() shows the first rows, shape the row and column count, info() each column's dtype and non-null count, and describe() summary statistics.
I
iloc: select by position
df.iloc[rows, cols] selects by integer position, like Python lists: the end of a slice is excluded.
L
loc: select by label
df.loc[rows, cols] selects by index labels and column names, and accepts boolean masks.
R
read_csv
pd.read_csv reads a delimited text file into a DataFrame, guessing column types.
S
Sampling rows
sample(n) or sample(frac=0.1) picks random rows; nlargest and nsmallest return the top or bottom rows by a column.
Selecting columns
Square brackets with one name return a Series; with a list of names they return a DataFrame with those columns in that order.
T
The index
The index is the set of row labels.
W
Why Parquet over CSV
Parquet is a compressed, columnar file format that stores each column's type alongside the data.
Writing data out
Every reader has a writer: to_csv, to_excel, to_parquet, to_sql.
11 · Glossary, A to Z11 / 11