I'm trying to generate a mask for broadcasting into dataframes: a boolean series that indicates whether a given row is between two values. This is easy to do for single logical statement, say the last five elements in a dataframe:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(10,1))
mask = (df.index.values>4)
df.loc[mask,'column'] = range(0,5)
But how does one do the same thing with more intersectional statements? For example, instead of the last five components in the array, can I address rows 2 through 6? Trying to use an AND statement for the mask fails, and I can't use Between on dataframe index values.