Repository: vaexio/vaex

Issue:
[BUG-REPORT] - Unknown variables or column after copy a column
**Description**
When creating a new column identical to another, and asking the dataframe for the new column without the original,we get `KeyError: "Unknown variables or column`.

**Software information**
```
{'vaex': '4.0.0a10',
 'vaex-core': '4.0.0a16',
 'vaex-viz': '0.5.0.dev1',
 'vaex-hdf5': '0.7.0a6',
 'vaex-server': '0.4.0a2',
 'vaex-astro': '0.8.0a1',
 'vaex-jupyter': '0.6.0.dev1',
 'vaex-ml': '0.11.0a5'}
```
* On Mac
* From pip

**Reproduce**
```
import vaex
df = vaex.from_arrays(x=['a','b'])
df['y'] = df['x']
df[['y']]

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/scopes.py", line 102, in evaluate
    result = self[expression]
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/scopes.py", line 159, in __getitem__
    raise KeyError("Unknown variables or column: %r" % (variable,))
KeyError: "Unknown variables or column: 'x'"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/dataframe.py", line 3562, in table_part
    values[name] = df.evaluate(name)
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/dataframe.py", line 2626, in evaluate
    return self._evaluate_implementation(expression, i1=i1, i2=i2, out=out, selection=selection, filtered=filtered, array_type=array_type, parallel=parallel, chunk_size=chunk_size)
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/dataframe.py", line 5483, in _evaluate_implementation
    dtypes[expression] = dtype = df.data_type(expression).internal
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/dataframe.py", line 1968, in data_type
    data = self.evaluate(expression, 0, 1, filtered=True, array_type=array_type, parallel=False)
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/dataframe.py", line 2626, in evaluate
    return self._evaluate_implementation(expression, i1=i1, i2=i2, out=out, selection=selection, filtered=filtered, array_type=array_type, parallel=parallel, chunk_size=chunk_size)
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/dataframe.py", line 5570, in _evaluate_implementation
    value = scope.evaluate(expression)
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/scopes.py", line 102, in evaluate
    result = self[expression]
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/scopes.py", line 152, in __getitem__
    values = self.evaluate(expression)
  File "/Users/yonatanalexander/.virtualenvs/goldilocks/lib/python3.7/site-packages/vaex/scopes.py", line 108, in evaluate
    result = eval(expression, expression_namespace, self)
  File "<string>", line 1, in <module>
NameError: name 'x' is not defined
  #  y
  0  error
  1  error
```

**Workaround**
```
df['y'] = df['x']+'' # for str
df['y'] = df['x']+0 # for numeric
```


Discussion:
Reproduced with:
```
{'vaex': '4.0.0a13',
 'vaex-core': '4.0.0a19',
 'vaex-viz': '0.5.0.dev1',
 'vaex-hdf5': '0.7.0a6',
 'vaex-server': '0.4.0a3',
 'vaex-astro': '0.8.0a1',
 'vaex-jupyter': '0.6.0.dev1',
 'vaex-ml': '0.11.0a5'}
```


Resolving patch:
diff --git a/packages/vaex-core/vaex/dataframe.py b/packages/vaex-core/vaex/dataframe.py
--- a/packages/vaex-core/vaex/dataframe.py
+++ b/packages/vaex-core/vaex/dataframe.py
@@ -5111,7 +5111,8 @@ def track(name):
                         expression_columns.add(name)
                         expr = self[name]
                     # we expand it ourselves
-                    deps = expr.variables(expand_virtual=False)
+                    deps = expr.variables(ourself=True, expand_virtual=False)
+                    deps -= {name}
                     # the columns we didn't know we required yet
                     missing = deps - required
                     required.update(deps)


Test patch:
diff --git a/tests/copy_test.py b/tests/copy_test.py
--- a/tests/copy_test.py
+++ b/tests/copy_test.py
@@ -20,6 +20,13 @@ def test_non_existing_column(df_local):
         df.copy(column_names=['x', 'x_'])
 
 
+def test_copy_alias(df_local):
+    df = df_local
+    df['alias'] = df.x
+    dfc = df.copy(['alias'])
+    assert set(dfc.get_column_names(hidden=True)) == {'alias', '__x'}
+
+
 def test_copy_dependencies():
     df = vaex.from_scalars(x=1)
     df['y'] = df.x + 1