Repository: modin-project/modin

Issue:
In BaseOnPython execution, __getitem__ and loc give incorrect values for Modin boolean series key
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: MacOS Monterey 12.2.1 
- **Modin version** (`modin.__version__`):  cf0eb393daa41abdd8cdf32b52ceee938cdcbe1a
- **Python version**: Python 3.9.12
- **Code we can use to reproduce**:

Try the following unit test with `BaseOnPython` execution (I don't know any other way to get that execution):

```python
import modin.pandas as pd
import pandas

  frame_data = [[15], [16]]
  key_data = [True, False]
  df_equals(
      pd.DataFrame(frame_data)[pd.Series(key_data)],
      pandas.DataFrame(frame_data)[pandas.Series(key_data)],
  )
```

### Describe the problem
For the unit test above, Modin gives 

```python
df1 =     0
0 NaN
1 NaN
```

but pandas drops the second row:

```python
df2 =     0
0  15
```


### Source code / logs
The cause is that the base query compiler will try calling `to_pandas()` on any key that has that method, but calling `to_pandas` on the query compiler of the Modin series key gives a pandas dataframe. we then try to use pandas getitem with the dataframe as a key, so we get the wrong semantics.


Discussion:

Resolving patch:
diff --git a/modin/core/storage_formats/base/query_compiler.py b/modin/core/storage_formats/base/query_compiler.py
--- a/modin/core/storage_formats/base/query_compiler.py
+++ b/modin/core/storage_formats/base/query_compiler.py
@@ -2011,6 +2011,8 @@ def getitem_array(self, key):
         BaseQueryCompiler
             New masked QueryCompiler.
         """
+        if isinstance(key, type(self)):
+            key = key.to_pandas().squeeze(axis=1)
 
         def getitem_array(df, key):
             return df[key]


Test patch:
diff --git a/modin/pandas/test/dataframe/test_indexing.py b/modin/pandas/test/dataframe/test_indexing.py
--- a/modin/pandas/test/dataframe/test_indexing.py
+++ b/modin/pandas/test/dataframe/test_indexing.py
@@ -315,13 +315,22 @@ def test_loc(data):
     # DataFrame
     df_equals(modin_df.loc[[1, 2]], pandas_df.loc[[1, 2]])
 
-    # List-like of booleans
     indices = [i % 3 == 0 for i in range(len(modin_df.index))]
     columns = [i % 5 == 0 for i in range(len(modin_df.columns))]
+
+    # Key is a list of booleans
     modin_result = modin_df.loc[indices, columns]
     pandas_result = pandas_df.loc[indices, columns]
     df_equals(modin_result, pandas_result)
 
+    # Key is a Modin or pandas series of booleans
+    df_equals(
+        modin_df.loc[pd.Series(indices), pd.Series(columns, index=modin_df.columns)],
+        pandas_df.loc[
+            pandas.Series(indices), pandas.Series(columns, index=modin_df.columns)
+        ],
+    )
+
     modin_result = modin_df.loc[:, columns]
     pandas_result = pandas_df.loc[:, columns]
     df_equals(modin_result, pandas_result)
@@ -1504,6 +1513,28 @@ def test___getitem__(data):
     df_equals(pd.DataFrame([])[:10], pandas.DataFrame([])[:10])
 
 
+@pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
+def test___getitem_bool_indexers(data):
+    modin_df = pd.DataFrame(data)
+    pandas_df = pandas.DataFrame(data)
+
+    indices = [i % 3 == 0 for i in range(len(modin_df.index))]
+    columns = [i % 5 == 0 for i in range(len(modin_df.columns))]
+
+    # Key is a list of booleans
+    modin_result = modin_df.loc[indices, columns]
+    pandas_result = pandas_df.loc[indices, columns]
+    df_equals(modin_result, pandas_result)
+
+    # Key is a Modin or pandas series of booleans
+    df_equals(
+        modin_df.loc[pd.Series(indices), pd.Series(columns, index=modin_df.columns)],
+        pandas_df.loc[
+            pandas.Series(indices), pandas.Series(columns, index=modin_df.columns)
+        ],
+    )
+
+
 def test_getitem_empty_mask():
     # modin-project/modin#517
     modin_frames = []