Repository: modin-project/modin

Issue:
BUG: AttributeError: module 'collections' has no attribute 'Sequence' in dataframe protocol
### 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
In a Python 3.10 environment: pytest 'modin/test/interchange/dataframe_protocol/test_general.py'.
```


### Issue Description

Python deprecated `collections.Sequence` in 3.7, and has made referencing it an error in 3.10 (https://stackoverflow.com/questions/69596494/unable-to-import-freegames-python-package-attributeerror-module-collections). The correct reference is now `collections.abc.Sequence`.

### Expected Behavior

No error occurs.

### Error Logs

<details>
<summary>pytest output</summary>
<pre>
================================================================================== FAILURES ===================================================================================
_______________________________________________________________________________ test_dataframe ________________________________________________________________________________

df_from_dict = <function df_from_dict.<locals>.maker at 0x7fb493714ca0>

    def test_dataframe(df_from_dict):
        df = df_from_dict(
            {"x": [True, True, False], "y": [1, 2, 0], "z": [9.2, 10.5, 11.8]}
        )
        dfX = df.__dataframe__()
    
        assert dfX.num_columns() == 3
        assert dfX.num_rows() == 3
        assert dfX.num_chunks() == 1
        assert list(dfX.column_names()) == ["x", "y", "z"]
>       assert list(dfX.select_columns((0, 2)).column_names()) == list(
            dfX.select_columns_by_name(("x", "z")).column_names()
        )

modin/test/interchange/dataframe_protocol/test_general.py:115: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <modin.core.dataframe.pandas.interchange.dataframe_protocol.dataframe.PandasProtocolDataframe object at 0x7fb493701d20>, indices = (0, 2)

    def select_columns(self, indices: Sequence[int]) -> "PandasProtocolDataframe":
>       if not isinstance(indices, collections.Sequence):
E       AttributeError: module 'collections' has no attribute 'Sequence'

modin/core/dataframe/pandas/interchange/dataframe_protocol/dataframe.py:130: AttributeError

---------- coverage: platform darwin, python 3.10.4-final-0 ----------
Coverage XML written to file coverage.xml

=========================================================================== short test summary info ===========================================================================
FAILED modin/test/interchange/dataframe_protocol/test_general.py::test_dataframe - AttributeError: module 'collections' has no attribute 'Sequence'
</pre>
</details>


### Installed Versions

<details>
UserWarning: Setuptools is replacing distutils.

INSTALLED VERSIONS
------------------
commit           : 2e3c5537b2448a407e23347d03d0cd1d7188f3b4
python           : 3.10.4.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 21.6.0
Version          : Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

Modin dependencies
------------------
modin            : 0.16.0+37.g2e3c5537
ray              : 1.13.0
dask             : 2022.8.0
distributed      : 2022.8.0
hdk              : None

pandas dependencies
-------------------
pandas           : 1.5.1
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      : 0.8.2
fsspec           : 2022.7.1
gcsfs            : None
matplotlib       : 3.5.3
numba            : None
numexpr          : 2.8.3
odfpy            : None
openpyxl         : 3.0.10
pandas_gbq       : 0.17.8
pyarrow          : 8.0.0
pyreadstat       : None
pyxlsb           : None
s3fs             : 2022.7.1
scipy            : 1.9.0
snappy           : None
sqlalchemy       : 1.4.40
tables           : 3.7.0
tabulate         : None
xarray           : 2022.6.0
xlrd             : 2.0.1
xlwt             : None
zstandard        : None
tzdata           : None
</details>



Discussion:

Resolving patch:
diff --git a/modin/core/dataframe/pandas/interchange/dataframe_protocol/dataframe.py b/modin/core/dataframe/pandas/interchange/dataframe_protocol/dataframe.py
--- a/modin/core/dataframe/pandas/interchange/dataframe_protocol/dataframe.py
+++ b/modin/core/dataframe/pandas/interchange/dataframe_protocol/dataframe.py
@@ -127,7 +127,7 @@ def get_columns(self) -> Iterable[PandasProtocolColumn]:
             )
 
     def select_columns(self, indices: Sequence[int]) -> "PandasProtocolDataframe":
-        if not isinstance(indices, collections.Sequence):
+        if not isinstance(indices, collections.abc.Sequence):
             raise ValueError("`indices` is not a sequence")
 
         return PandasProtocolDataframe(
@@ -138,7 +138,7 @@ def select_columns(self, indices: Sequence[int]) -> "PandasProtocolDataframe":
         )
 
     def select_columns_by_name(self, names: Sequence[str]) -> "PandasProtocolDataframe":
-        if not isinstance(names, collections.Sequence):
+        if not isinstance(names, collections.abc.Sequence):
             raise ValueError("`names` is not a sequence")
 
         return PandasProtocolDataframe(
diff --git a/modin/experimental/core/execution/native/implementations/hdk_on_native/interchange/dataframe_protocol/dataframe.py b/modin/experimental/core/execution/native/implementations/hdk_on_native/interchange/dataframe_protocol/dataframe.py
--- a/modin/experimental/core/execution/native/implementations/hdk_on_native/interchange/dataframe_protocol/dataframe.py
+++ b/modin/experimental/core/execution/native/implementations/hdk_on_native/interchange/dataframe_protocol/dataframe.py
@@ -246,7 +246,7 @@ def get_columns(self) -> Iterable[HdkProtocolColumn]:
             )
 
     def select_columns(self, indices: Sequence[int]) -> "HdkProtocolDataframe":
-        if not isinstance(indices, collections.Sequence):
+        if not isinstance(indices, collections.abc.Sequence):
             raise ValueError("`indices` is not a sequence")
 
         return HdkProtocolDataframe(
@@ -256,7 +256,7 @@ def select_columns(self, indices: Sequence[int]) -> "HdkProtocolDataframe":
         )
 
     def select_columns_by_name(self, names: Sequence[str]) -> "HdkProtocolDataframe":
-        if not isinstance(names, collections.Sequence):
+        if not isinstance(names, collections.abc.Sequence):
             raise ValueError("`names` is not a sequence")
 
         return HdkProtocolDataframe(


Test patch: