Closed
Description
It's not clear from the docs that indexing with a boolean ndarray
isn't the same as indexing with a boolean Series
. It took me a while to realise that:
import pandas as pd
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], list('abc'), ['one', 'two'])
sr = (df['one'] > 2)
df.loc[sr, 'two'] # This is ok
df.iloc[sr, 1] # But this is not
df.iloc[sr.values, 1] # The right way to use iloc
I've since read through #3631 and it makes sense to me. However, even though the docs emphasise that .iloc
is purely integer-based, it didn't click at the time that indexability of Series
was the problem I was facing.