Repository: modin-project/modin

Issue:
BUG: setting dataframe index or columns raises UserWarning: Modin doesn't allow columns to be created via a new attribute name
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: MacOS Monterey 12.4
- **Modin version** (`modin.__version__`): 05933a5f27fb96f5a7ff6025ae2573d033a31b11
- **Python version**: 3.9.12
- **Code we can use to reproduce**:

```python
import modin.pandas as pd
pd.DataFrame().index = []
```

### Describe the problem
Modin raises `UserWarning: Distributing <class 'NoneType'> object. This may take some time.
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` when we set `column` in the code above, but pandas does not.

### Source code / logs
We should fix the check [here](https://github.com/modin-project/modin/blob/eddfda4b521366c628596dcb5c21775c7f50eec1/modin/pandas/dataframe.py#L2506) so that it only warns when setting an attribute like `index` or columns` that is already in `dir(self)`.


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
@@ -2367,7 +2367,7 @@ def __setattr__(self, key, value):
             # `__getattr__` will return the columns not present in `dir(self)`, so we do not need
             # to manually track this state in the `dir`.
             return
-        elif is_list_like(value):
+        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",


Test patch:
diff --git a/modin/pandas/test/dataframe/test_default.py b/modin/pandas/test/dataframe/test_default.py
--- a/modin/pandas/test/dataframe/test_default.py
+++ b/modin/pandas/test/dataframe/test_default.py
@@ -16,9 +16,13 @@
 import pandas
 import matplotlib
 import modin.pandas as pd
-from modin.utils import to_pandas
+from modin.utils import (
+    to_pandas,
+    get_current_execution,
+)
 from numpy.testing import assert_array_equal
 import io
+import warnings
 
 from modin.pandas.test.utils import (
     df_equals,
@@ -1171,3 +1175,19 @@ def test_hasattr_sparse(is_sparse_data):
         else create_test_dfs(test_data["float_nan_data"])
     )
     eval_general(modin_df, pandas_df, lambda df: hasattr(df, "sparse"))
+
+
+def test_setattr_axes():
+    # Test that setting .index or .columns does not warn
+    df = pd.DataFrame([[1, 2], [3, 4]])
+    with warnings.catch_warnings():
+        if get_current_execution() != "BaseOnPython":
+            # In BaseOnPython, setting columns raises a warning because get_axis
+            #  defaults to pandas.
+            warnings.simplefilter("error")
+        df.index = ["foo", "bar"]
+        df.columns = [9, 10]
+
+    # Check that ensure_index was called
+    pandas.testing.assert_index_equal(df.index, pandas.Index(["foo", "bar"]))
+    pandas.testing.assert_index_equal(df.columns, pandas.Index([9, 10]))