My aim is to use boolean mask to get useful columns from DataFrame.
I try such snippet of code:
df = pd.DataFrame({'a': [1,2,3,4,5], 'b': [101, 101, 102, 101, 102], 'c': [23, 12, 54, 65, 21]})
mask = [True, False, True]
df.columns[mask]
And the result is what I actually need:
Index([u'a', u'c'], dtype='object')
Then I try the same code but with another mask:
mask_i = [1, 0, 1]
df = pd.DataFrame({'a': [1,2,3,4,5], 'b': [101, 101, 102, 101, 102], 'c': [23, 12, 54, 65, 21]})
mask_i = [1, 0, 1]
df.columns[mask]
I expected the same result, but get all indexes:
Index([u'b', u'a', u'b'], dtype='object')
Then I check:
mask_i = [1, 0, 1]
mask = [True, False, True]
print mask == mask_i`
# Result: `True`
Can somebody explain please why masks are equal but I get different results.