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 df["colB"] df.colA # Accessing a single element in a DataFrame df["colB"]["R3"], df["colB"][1]
Code language: Python (python)

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

Leave a Comment