Repository: innobi/pantab (python)

Issue:
ENH: Support datetime64[ns, UTC}
Though utility in Tableau is limited this should be allowable

Pull request description:
Add utc support
closes #8 

Patch:
diff --git a/pantab/_pantab.py b/pantab/_pantab.py
index 33c021e..1d4c69b 100644
--- a/pantab/_pantab.py
+++ b/pantab/_pantab.py
@@ -20,6 +20,7 @@ _type_mappings = (
     ("float64", tab_api.TypeTag.DOUBLE, "float64"),
     ("bool", tab_api.TypeTag.BOOL, "bool"),
     ("datetime64[ns]", tab_api.TypeTag.TIMESTAMP, "datetime64[ns]"),
+    ("datetime64[ns, UTC]", tab_api.TypeTag.TIMESTAMP_TZ, "datetime64[ns, UTC]"),
     ("timedelta64[ns]", tab_api.TypeTag.INTERVAL, "timedelta64[ns]"),
     ("object", tab_api.TypeTag.TEXT, "object"),
 )
@@ -149,6 +150,8 @@ def _read_table(*, connection: tab_api.Connection, table: TableType) -> pd.DataF
     for key, val in dtypes.items():
         if val == "datetime64[ns]":
             df[key] = df[key].apply(lambda x: x._to_datetime())
+        elif val == "datetime64[ns, UTC]":
+            df[key] = df[key].apply(lambda x: x._to_datetime()).dt.tz_localize("UTC")
         elif val == "timedelta64[ns]":
             df[key] = df[key].apply(_interval_to_timedelta)
 


Test patch:
diff --git a/pantab/tests/test_pantab.py b/pantab/tests/test_pantab.py
index 42150b7..849d4c1 100644
--- a/pantab/tests/test_pantab.py
+++ b/pantab/tests/test_pantab.py
@@ -21,7 +21,8 @@ def df():
                 4.0,
                 5.0,
                 True,
-                pd.to_datetime("1/1/18"),
+                pd.to_datetime("2018-01-01"),
+                pd.to_datetime("2018-01-01", utc=True),
                 pd.Timedelta("1 days 2 hours 3 minutes 4 seconds"),
                 "foo",
             ],
@@ -31,10 +32,11 @@ def df():
                 8,
                 9.0,
                 10.0,
-                True,
+                False,
                 pd.to_datetime("1/1/19"),
+                pd.to_datetime("2019-01-01", utc=True),
                 pd.Timedelta("-1 days 2 hours 3 minutes 4 seconds"),
-                "foo",
+                "bar",
             ],
         ],
         columns=[
@@ -45,6 +47,7 @@ def df():
             "float64",
             "bool",
             "datetime64",
+            "datetime64_utc",
             "timedelta64",
             "object",
         ],
@@ -59,6 +62,7 @@ def df():
             "float64": np.float64,
             "bool": np.bool,
             "datetime64": "datetime64[ns]",
+            "datetime64_utc": "datetime64[ns, UTC]",
             "timedelta64": "timedelta64[ns]",
             "object": "object",
         }
@@ -174,9 +178,7 @@ def test_duplicate_columns_raises(tmp_hyper):
         pantab.frames_to_hyper({"test": df}, tmp_hyper)
 
 
-@pytest.mark.parametrize(
-    "dtype", ["Int64", "UInt64", "datetime64[ns, US/Eastern]", "datetime64[ns, UTC]"]
-)
+@pytest.mark.parametrize("dtype", ["Int64", "UInt64", "datetime64[ns, US/Eastern]"])
 def test_unsupported_dtype_raises(dtype, tmp_hyper):
     df = pd.DataFrame([[1]], dtype=dtype)