Search⌘ K

Indexing and Slicing

Explore methods to index and slice Pandas DataFrames effectively. Understand how to select columns, rows, and specific values using [] and iloc, and apply lambda functions for conditional data filtering.

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.

Python 3.5
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 ...