Repository: modin-project/modin

Issue:
When I run `ap.user_id = ap.item_id`, everything does not change, Why?
<!--
General questions should be asked on the mailing list modin-dev@googlegroups.com.

Before submitting an issue, please fill out the following form.
-->

### System information
- **OS Platform and Distribution tlinux 2.2**:
- **Modin installed from pip **:
- **Modin version 0.2.4**:
- **Python version 3.6.1**:
- **Exact command to reproduce**:

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
<!-- Describe the problem clearly here. -->

The data do not change, when I run the code like this:
```python
ap.user_id = ap.item_id
```

After I run the code above, the value of `ap.user_id` is the same as before and do not change into `ap.item_id`, Why?

The structure of data:

![image](https://user-images.githubusercontent.com/16526817/51519401-d53e5500-1e5b-11e9-8fcc-edb12be80592.png)
 

### Source code / logs
<!-- Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem. -->

Now, I provide the code which you can reproduce my result quickly:
```python
import numpy as np
import modin.pandas as pd

a = np.array([['bdgr3fom129hsoj6488g', '6UExPoNGS1GCWqPfb', 20190101105500, 0.0],
 ['bdgr3fom129hsoj6488g', '6VhJvfi041GCOisdI', 20190101105429, 0.0],
['bdgr3fom129hsoj6488g', '6ViNKCMMV1GCIQQAT', 20190101105409, 0.0],
 ['bdgr3fom129hsoj6488g', '6WIkLrUBL1GvSKkKv', 20190101105142, 0.0],
 ['bdgr3fom129hsoj6488g', '6WMEaqk7A1GvTYOjp', 20190101105006, 0.0]])

ap = pd.DataFrame(a)
print (ap)
ap.columns = ["user_id", "item_id", "reporttime", "label"]
ap.user_id = ap.item_id
print (ap)
```



Discussion:
Hi @JyiHUO, great question! The currently supported way to set a column in Modin is 
```
ap["user_id"] = ap.item_id
```

To support this behavior, pandas is doing a `__setattr__` override to allow setting of existing columns. This should be relatively simple to implement and can certainly make it in the next release.

Resolving patch:
diff --git a/modin/pandas/dataframe.py b/modin/pandas/dataframe.py
--- a/modin/pandas/dataframe.py
+++ b/modin/pandas/dataframe.py
@@ -4608,6 +4608,21 @@ def __getattr__(self, key):
                 return self[key]
             raise e
 
+    def __setattr__(self, key, value):
+        # We have to check for this first because we have to be able to set
+        # _query_compiler before we check if the key is in self
+        if key in ["_query_compiler"] or key in self.__dict__:
+            pass
+        elif key in self:
+            self.__setitem__(key, value)
+        elif isinstance(value, pandas.Series):
+            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",
+                UserWarning,
+            )
+        object.__setattr__(self, key, value)
+
     def __setitem__(self, key, value):
         if not isinstance(key, str):
             return self._default_to_pandas(pandas.DataFrame.__setitem__, key, value)


Test patch: