Repository: modin-project/modin

Issue:
BUG: series iloc accepts 2 parameters
### 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
import modin.pandas as pd

s = pd.Series(0)
print(s.iloc[0, 0])
```


### Issue Description

Series and dataframe `iloc` return the same kind of `modin.pandas.indexing._iLocIndexer`, so you can select the first row and first column of the series even though the series has only rows.

### Expected Behavior

pandas raises an exception:

<details>
<summary>stack trace</summary>

```python-traceback
---------------------------------------------------------------------------
IndexingError                             Traceback (most recent call last)
Input In [15], in <cell line: 1>()
----> 1 sp.iloc[0, 0]

File ~/opt/anaconda3/envs/modin-dev-py38/lib/python3.8/site-packages/pandas/core/indexing.py:1067, in _LocationIndexer.__getitem__(self, key)
   1065     if self._is_scalar_access(key):
   1066         return self.obj._get_value(*key, takeable=self._takeable)
-> 1067     return self._getitem_tuple(key)
   1068 else:
   1069     # we by definition only have the 0th axis
   1070     axis = self.axis or 0

File ~/opt/anaconda3/envs/modin-dev-py38/lib/python3.8/site-packages/pandas/core/indexing.py:1563, in _iLocIndexer._getitem_tuple(self, tup)
   1561 def _getitem_tuple(self, tup: tuple):
-> 1563     tup = self._validate_tuple_indexer(tup)
   1564     with suppress(IndexingError):
   1565         return self._getitem_lowerdim(tup)

File ~/opt/anaconda3/envs/modin-dev-py38/lib/python3.8/site-packages/pandas/core/indexing.py:869, in _LocationIndexer._validate_tuple_indexer(self, key)
    864 @final
    865 def _validate_tuple_indexer(self, key: tuple) -> tuple:
    866     """
    867     Check the key for valid keys across my indexer.
    868     """
--> 869     key = self._validate_key_length(key)
    870     key = self._expand_ellipsis(key)
    871     for i, k in enumerate(key):

File ~/opt/anaconda3/envs/modin-dev-py38/lib/python3.8/site-packages/pandas/core/indexing.py:908, in _LocationIndexer._validate_key_length(self, key)
    906             raise IndexingError(_one_ellipsis_message)
    907         return self._validate_key_length(key)
--> 908     raise IndexingError("Too many indexers")
    909 return key

IndexingError: Too many indexers
```


</details>

### Error Logs

n/a

### Installed Versions

<details>
<summary>Details</summary>

UserWarning: Setuptools is replacing distutils.

INSTALLED VERSIONS
------------------
commit           : 68b1f86b00e2492107168c1ad2f56d6277edce76
python           : 3.8.13.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 21.5.0
Version          : Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

Modin dependencies
------------------
modin            : 0.17.0+33.g68b1f86b
ray              : 2.1.0
dask             : 2022.11.1
distributed      : None
hdk              : None

pandas dependencies
-------------------
pandas           : 1.5.2
numpy            : 1.23.1
pytz             : 2022.1
dateutil         : 2.8.2
setuptools       : 61.2.0
pip              : 22.1.2
Cython           : None
pytest           : 7.1.2
hypothesis       : None
sphinx           : 5.1.1
blosc            : None
feather          : 0.4.1
xlsxwriter       : None
lxml.etree       : 4.9.1
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : 3.1.2
IPython          : 8.4.0
pandas_datareader: None
bs4              : 4.11.1
bottleneck       : None
brotli           : None
fastparquet      : 2022.11.0
fsspec           : 2022.7.1
gcsfs            : None
matplotlib       : 3.5.2
numba            : None
numexpr          : 2.8.3
odfpy            : None
openpyxl         : 3.0.10
pandas_gbq       : 0.17.7
pyarrow          : 8.0.0
pyreadstat       : None
pyxlsb           : None
s3fs             : 2022.7.1
scipy            : 1.9.0
snappy           : None
sqlalchemy       : 1.4.39
tables           : 3.7.0
tabulate         : 0.9.0
xarray           : 2022.6.0
xlrd             : 2.0.1
xlwt             : None
zstandard        : None
tzdata           : None
</details>


Discussion:

Resolving patch:
diff --git a/modin/pandas/indexing.py b/modin/pandas/indexing.py
--- a/modin/pandas/indexing.py
+++ b/modin/pandas/indexing.py
@@ -233,6 +233,8 @@ def boolean_mask_to_numeric(indexer):
 INCLUDED, END point is EXCLUDED), listlike of integers, boolean array] types.
 """
 
+_one_ellipsis_message = "indexer may only contain one '...' entry"
+
 
 def _compute_ndim(row_loc, col_loc):
     """
@@ -277,6 +279,20 @@ def __init__(self, modin_df):
         self.df = modin_df
         self.qc = modin_df._query_compiler
 
+    def _validate_key_length(self, key: tuple) -> tuple:  # noqa: GL08
+        # Implementation copied from pandas.
+        if len(key) > self.df.ndim:
+            if key[0] is Ellipsis:
+                # e.g. Series.iloc[..., 3] reduces to just Series.iloc[3]
+                key = key[1:]
+                if Ellipsis in key:
+                    raise IndexingError(_one_ellipsis_message)
+                return self._validate_key_length(key)
+            raise IndexingError(
+                f"Too many indexers: you're trying to pass {len(key)} indexers to the {type(self.df)} having only {self.df.ndim} dimensions."
+            )
+        return key
+
     def __getitem__(self, key):  # pragma: no cover
         """
         Retrieve dataset according to `key`.
@@ -632,7 +648,8 @@ def __getitem__(self, key):
         """
         if self.df.empty:
             return self.df._default_to_pandas(lambda df: df.loc[key])
-
+        if isinstance(key, tuple):
+            key = self._validate_key_length(key)
         if (
             isinstance(key, tuple)
             and len(key) == 2
@@ -987,6 +1004,8 @@ def __getitem__(self, key):
         """
         if self.df.empty:
             return self.df._default_to_pandas(lambda df: df.iloc[key])
+        if isinstance(key, tuple):
+            key = self._validate_key_length(key)
         row_loc, col_loc, ndim = self._parse_row_and_column_locators(key)
         row_scalar = is_scalar(row_loc)
         col_scalar = is_scalar(col_loc)


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
@@ -832,6 +832,12 @@ def test_iloc_empty():
     df_equals(pandas_df, modin_df)
 
 
+def test_iloc_loc_key_length():
+    modin_ser, pandas_ser = pd.Series(0), pandas.Series(0)
+    eval_general(modin_ser, pandas_ser, lambda ser: ser.iloc[0, 0])
+    eval_general(modin_ser, pandas_ser, lambda ser: ser.loc[0, 0])
+
+
 def test_loc_series():
     md_df, pd_df = create_test_dfs({"a": [1, 2], "b": [3, 4]})
 
diff --git a/modin/pandas/test/test_series.py b/modin/pandas/test/test_series.py
--- a/modin/pandas/test/test_series.py
+++ b/modin/pandas/test/test_series.py
@@ -16,6 +16,7 @@
 import json
 import pandas
 from pandas.errors import SpecificationError
+from pandas.core.indexing import IndexingError
 import matplotlib
 import modin.pandas as pd
 from numpy.testing import assert_array_equal
@@ -2010,8 +2011,7 @@ def test_iloc(request, data):
         modin_series.iloc[[1, 2]] = 42
         pandas_series.iloc[[1, 2]] = 42
         df_equals(modin_series, pandas_series)
-
-        with pytest.raises(IndexError):
+        with pytest.raises(IndexingError):
             modin_series.iloc[1:, 1]
     else:
         with pytest.raises(IndexError):