Repository: modin-project/modin

Issue:
BUG: printing a dataframe creates warning because of initializing _cache attribute
### 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
df = pd.DataFrame([1])
print(df)
```


### Issue Description

This is a regression caused by #5311. pandas `cache_readonly` sets `_cache` to a dictionary of cached values, and Modin doesn't recognize that `_cache` is a special name.

### Expected Behavior

No warning	

### Error Logs


```python-traceback

UserWarning: Modin doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access

```



### Installed Versions

<details>

INSTALLED VERSIONS
------------------
commit           : 2bb9a1fab7b0092974853e616dfd5e7ed98f085d
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+70.g2bb9a1fa
ray              : 2.1.0
dask             : 2022.12.0
distributed      : 2022.12.0
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/dataframe.py b/modin/pandas/dataframe.py
--- a/modin/pandas/dataframe.py
+++ b/modin/pandas/dataframe.py
@@ -56,6 +56,7 @@
     from_pandas,
     from_non_pandas,
     broadcast_item,
+    SET_DATAFRAME_ATTRIBUTE_WARNING,
 )
 from . import _update_engine
 from .iterator import PartitionIterator
@@ -2662,7 +2663,9 @@ def __setattr__(self, key, value):
         # - `_query_compiler`, which Modin initializes before it appears in
         #   __dict__
         # - `_siblings`, which Modin initializes before it appears in __dict__
-        if key in ["_query_compiler", "_siblings"] or key in self.__dict__:
+        # - `_cache`, which pandas.cache_readonly uses to cache properties
+        #   before it appears in __dict__.
+        if key in ("_query_compiler", "_siblings", "_cache") or key in self.__dict__:
             pass
         elif key in self and key not in dir(self):
             self.__setitem__(key, value)
@@ -2672,8 +2675,7 @@ def __setattr__(self, key, value):
             return
         elif is_list_like(value) and key not in ["index", "columns"]:
             warnings.warn(
-                "Modin doesn't allow columns to be created via a new attribute name - see "
-                + "https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access",
+                SET_DATAFRAME_ATTRIBUTE_WARNING,
                 UserWarning,
             )
         object.__setattr__(self, key, value)
diff --git a/modin/pandas/utils.py b/modin/pandas/utils.py
--- a/modin/pandas/utils.py
+++ b/modin/pandas/utils.py
@@ -32,6 +32,11 @@
 {returns}
 """
 
+SET_DATAFRAME_ATTRIBUTE_WARNING = (
+    "Modin doesn't allow columns to be created via a new attribute name - see "
+    + "https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access"
+)
+
 
 def from_non_pandas(df, index, columns, dtype):
     """


Test patch:
diff --git a/modin/pandas/test/dataframe/test_iter.py b/modin/pandas/test/dataframe/test_iter.py
--- a/modin/pandas/test/dataframe/test_iter.py
+++ b/modin/pandas/test/dataframe/test_iter.py
@@ -30,6 +30,7 @@
     create_test_dfs,
     test_data,
 )
+from modin.pandas.utils import SET_DATAFRAME_ATTRIBUTE_WARNING
 from modin.config import NPartitions
 from modin.test.test_utils import warns_that_defaulting_to_pandas
 
@@ -232,6 +233,14 @@ def test___repr__():
     assert repr(pandas_df) == repr(modin_df)
 
 
+def test___repr__does_not_raise_attribute_column_warning():
+    # See https://github.com/modin-project/modin/issues/5380
+    df = pd.DataFrame([1])
+    with warnings.catch_warnings():
+        warnings.filterwarnings(action="error", message=SET_DATAFRAME_ATTRIBUTE_WARNING)
+        repr(df)
+
+
 @pytest.mark.parametrize("data", test_data_values, ids=test_data_keys)
 def test_inplace_series_ops(data):
     pandas_df = pandas.DataFrame(data)
@@ -294,16 +303,14 @@ def test___setattr__mutating_column():
     # and adds the provided list as a new attribute and not a column.
     with pytest.warns(
         UserWarning,
-        match="Modin doesn't allow columns to be created via a new attribute name - see "
-        + "https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access",
+        match=SET_DATAFRAME_ATTRIBUTE_WARNING,
     ):
         modin_df.col1 = [4]
 
     with warnings.catch_warnings():
         warnings.filterwarnings(
             action="error",
-            message="Modin doesn't allow columns to be created via a new attribute name - see "
-            + "https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access",
+            message=SET_DATAFRAME_ATTRIBUTE_WARNING,
         )
         modin_df.col1 = [5]
         modin_df.new_attr = 6