Pandas Series .loc: Selecting with labels and booleans

Pandas Series .loc: Selecting with labels and booleans

Retrieve from a Python Pandas series with .loc and indexes:

s = pd.Series([10, 20, 30], index=list('abc'))
s.loc[['a', 'c']]  # [10, 30]

If you pass booleans, True means “return a value,” and False means “ignore it.”

s.loc[[True, False, True]] # [10, 30]