Lesson 7 Pandas Splitting Logic

In chapter 9/lesson 7, for the Rossman sales dataset, the TrainAndValid df is split using the following logic:

cond = (df.saleYear<2011) | (df.saleMonth<10)
train_idx = np.where( cond)[0]
valid_idx = np.where(~cond)[0]

splits = (list(train_idx),list(valid_idx))

I am a little confused by the bitwise operation here. Wouldn’t this check for cases where saleYear is less than 2011 or saleMonth is less than 10.

For example, if we have (2, 2012) or February 2012, the condition would be False | True which would be True.

Could somebody explain how the splitting condition works?

In pandas it has different meaning: or
for more details check out this question and answer https://stackoverflow.com/a/46350913/3467942

Thanks! That clarified it.