Indexing and Slicing

Let's learn how to index data in Pandas.

Get a single column

Getting a column from pandas is very simple, just use the [] operation with the column name or column index, and the column is returned as a Series.

Press + to interact
main.py
sample.csv
import pandas as pd
df = pd.read_csv("sample.csv", sep=",")
col = df["uniq_id"]
print("The value of the \"uniq_id\" column is {}".format(col.values))

Line 4 shows how to access a single column using the [] operation and a column name, uniq_id.

Get data by location

Just like a Numpy ndarray and native ...