Columns and Slices in Python

From the Pandas cheat sheet ยท Select Rows and Columns ยท verified Aug 2026

Columns and Slices

Select one or multiple columns and row slices.

python
names = df["name"]
subset = df[["name", "score"]]
๐Ÿ“Œ One column returns a Series
๐Ÿ” A column list returns a DataFrame
๐Ÿ’ก select_dtypes avoids hard-coded column lists
โš ๏ธ Plain slices apply to rows, not columns
columnsselectionslice

Continue with Pandas

Save the full cheat sheet or work through every related task.

More Python tasks

Back to the full Pandas cheat sheet