Repository: modin-project/modin

Issue:
BUG: KeyError: "None of [Index([()], dtype='object')] are in the [columns]"
### Modin version checks

- [X] I have checked that this issue has not already been reported.

- [X] I have confirmed this bug exists on the latest released version of Modin.

- [X] I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow [this guide](https://modin.readthedocs.io/en/stable/getting_started/installation.html#installing-from-the-github-master-branch).)


### Reproducible Example

```python
from modin.config import MinPartitionSize
import modin.pandas as pd
import pandas
import numpy as np

size = MinPartitionSize.get()

pandas_series = pandas.Series([True if i % 2 else False for i in range(size)])
modin_series = pd.Series(pandas_series)

pandas_df = pandas.DataFrame([i for i in range(size + 1)])
pandas_df.iloc[size] = np.nan
modin_df = pd.DataFrame(pandas_df)

pandas_tmp_result = pandas_df.dropna()
modin_tmp_result = modin_df.dropna()

pandas_result = pandas_tmp_result[pandas_series]
print(pandas_result)
modin_result = modin_tmp_result[modin_series]
print(modin_result)
KeyError: "None of [Index([()], dtype='object')] are in the [columns]"
```


### Issue Description

The error is raised when the key, i.e. modin series, has an empty partition.

### Expected Behavior

Should match pandas behavior.

### Error Logs

<details>

```python-traceback

Replace this line with the error backtrace (if applicable).

```

</details>


### Installed Versions

<details>

Replace this line with the output of pd.show_versions()

</details>



Discussion:

Resolving patch:
diff --git a/modin/core/storage_formats/pandas/query_compiler.py b/modin/core/storage_formats/pandas/query_compiler.py
--- a/modin/core/storage_formats/pandas/query_compiler.py
+++ b/modin/core/storage_formats/pandas/query_compiler.py
@@ -21,6 +21,7 @@
 import numpy as np
 import pandas
 import functools
+from pandas.api.types import is_scalar
 from pandas.core.common import is_bool_indexer
 from pandas.core.indexing import check_bool_indexer
 from pandas.core.indexes.api import ensure_index_from_sequences
@@ -2181,8 +2182,7 @@ def applyier(df, internal_indices, other=[], internal_other_indices=[]):
 
     # __getitem__ methods
     __getitem_bool = Binary.register(
-        # r is usually a list, but when r.size == 1, the array is squeezed to a scalar
-        lambda df, r: df[r] if r.size > 1 else df[[r]],
+        lambda df, r: df[[r]] if is_scalar(r) else df[r],
         join_type="left",
         labels="drop",
     )


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
@@ -40,7 +40,7 @@
     extra_test_parameters,
     default_to_pandas_ignore_string,
 )
-from modin.config import NPartitions
+from modin.config import NPartitions, MinPartitionSize
 from modin.utils import get_current_execution
 from modin.test.test_utils import warns_that_defaulting_to_pandas
 from modin.pandas.indexing import is_range_like
@@ -2214,6 +2214,31 @@ def test__getitem_bool_single_row_dataframe():
     eval_general(pd, pandas, lambda lib: lib.DataFrame([1])[lib.Series([True])])
 
 
+def test__getitem_bool_with_empty_partition():
+    # This test case comes from
+    # https://github.com/modin-project/modin/issues/5188
+
+    size = MinPartitionSize.get()
+
+    pandas_series = pandas.Series([True if i % 2 else False for i in range(size)])
+    modin_series = pd.Series(pandas_series)
+
+    pandas_df = pandas.DataFrame([i for i in range(size + 1)])
+    pandas_df.iloc[size] = np.nan
+    modin_df = pd.DataFrame(pandas_df)
+
+    pandas_tmp_result = pandas_df.dropna()
+    modin_tmp_result = modin_df.dropna()
+
+    eval_general(
+        modin_tmp_result,
+        pandas_tmp_result,
+        lambda df: df[modin_series]
+        if isinstance(df, pd.DataFrame)
+        else df[pandas_series],
+    )
+
+
 # This is a very subtle bug that comes from:
 # https://github.com/modin-project/modin/issues/4945
 def test_lazy_eval_index():