Pandas Axis and Labels

Summary : in this tutorial, you’ll learn about the axes and labels in Pandas.

Pandas Axes

NumPy can be used to perform calculations on multi-dimensional arrays and matrices. Our data is normally available in tabular form, which can be represent in 2-dimensional array, equivalent to 2 axis.

The term axes in Pandas refer to the columns and the row index, as shown in the picture above.

The index is axis 0 and the columns are axis 1. Both are stored in Index objects and are immutable, meaning they cannot be changed once created.

Pandas Labels

The labels in pandas allows for quick and easy access to rows and columns data using names instead of numbers.

# Subset a single column by column name
# Accessing a single element in a DataFrame
df["colB"]["R3"], df["colB"][1]

More details on how to select data using labels can be found at Select DataFrame rows and Select DataFrame columns.

Author: Thijmen I’m currently a SysAdmin located in the Netherlands. Every day I try to keep around a hundred users happy with their network connections and overall, tech-related issues. I also spend my spare time fiddling with web-based applications.
See also  Read JSON files with Pandas

Leave a Comment