Numpy Boolean Indexing: Show False Values

test_1 = taxi[:4, :4]
test_bool = [True, True, False, False]
test_bool_results = test_1[:, test_bool]
test_bool_rows = test_1[test_bool, :]

If the Boolean Indexing allows you to pull the True values automatically; Is there a simple way to pull the False values also?

Invert the boolean indexer with ~ to get False values. If you want both False and True at the same time, that is basically not indexing at all.

How does it look when you use ~?

training_set = df[training_data_mask]
testing_set = df[~training_data_mask]

1 Like

It does not seem to work.

I saw it somewhere online as:

import numpy as np
a = np.array([[1,2,3], [4,5,6], [7,8,9]])

b = [True,False,True]

c = (~a[b])


but then I tried that… hence the edit :slight_smile:

I got this…

[[ -2 -3 -4]
[ -8 -9 -10]]