Repository: vaexio/vaex

Issue:
Joining dataframes on datetime column
Hello,

I am looking forward to optimize my project and replace Pandas with Vaex for the time series dataframes manipulation. Below is an example where I get issues: 

```
import vaex
import numpy as np
x = np.arange(5)
y = x**2
z = x**3
t1 = np.array(['2020-04-27T00:00:00.000000000', '2020-04-28T00:00:00.000000000',
              '2020-04-29T00:00:00.000000000', '2020-04-29T00:00:00.000000000',
              '2020-04-29T00:00:00.000000000'], dtype='datetime64[ns]')

t2 = np.array(['2020-04-27T00:00:00.000000000', '2020-04-28T00:00:00.000000000',
              '2020-04-29T00:00:00.000000000', '2020-04-29T00:00:00.000000000',
              '2020-04-29T00:00:00.000000000'], dtype='datetime64[ns]')

df1 = vaex.from_arrays(x=x, y=y, Date=t1)
df2 = vaex.from_arrays(z=z, Date=t2)

df = df1.join(df2, left_on='Date', right_on='Date')
df
```

Above code results in  `KeyError: 'index_hash_datetime64[ns]' ` .   

Thank you,


Discussion:

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
@@ -5884,6 +5884,8 @@ def map(thread_index, i1, i2, ar):
                 if vaex.array_types.is_string_type(dtype):
                     previous_ar = ar
                     ar = _to_string_sequence(ar)
+                if dtype.is_datetime:
+                    ar = ar.view(np.uint64)
                 if np.ma.isMaskedArray(ar):
                     mask = np.ma.getmaskarray(ar)
                     found_masked = index.map_index_masked(ar.data, mask, lookup[i1:i2])


Test patch:
diff --git a/tests/join_test.py b/tests/join_test.py
--- a/tests/join_test.py
+++ b/tests/join_test.py
@@ -37,6 +37,17 @@
                         x2=np.array([3.1, 25, np.nan]),
                         )
 
+df_dt1 = vaex.from_arrays(date=[np.datetime64('2009-10-12T03:00:00'),
+                                np.datetime64('2009-10-12T11:00:00'),
+                                np.datetime64('2009-10-12T12:00:00'),
+                                np.datetime64('2009-12-12T03:00:00')],
+                          value=[1, 2, 3, 4])
+
+df_dt2 = vaex.from_arrays(date=[np.datetime64('2009-10-12T03:00:00'),
+                                np.datetime64('2009-10-12T11:00:00'),
+                                np.datetime64('2009-12-12T03:00:00')],
+                          value=[11, 22, 44])
+
 
 def test_no_on():
     # just adds the columns
@@ -305,3 +316,14 @@ def test_with_masked_no_short_circuit():
     assert dfj[:10].dataset.right._columns['j'].masked
     assert dfj['j'][:10].tolist() == [0, 1, 2, 3, 4, 5, 6, 7, 8, None]
     dfj['j'].tolist()  # make sure we can evaluate the whole column
+
+
+def test_join_datetime():
+    df = df_dt1.join(df_dt2, on='date', rsuffix='_right', how='left')
+    assert df.shape == (4, 4)
+    assert df.value.tolist() == [1, 2, 3, 4]
+    assert df.value_right.tolist() == [11, 22, None, 44]
+    assert df.date_right.tolist() == [np.datetime64('2009-10-12T03:00:00'),
+                                      np.datetime64('2009-10-12T11:00:00'),
+                                      None,
+                                      np.datetime64('2009-12-12T03:00:00')]