Closed
Description
Code Sample, a copy-pastable example if possible
import pandas as pd
import numpy as np
array_dim2 = np.arange(10).reshape((5, 2))
df = pd.DataFrame(array_dim2 , dtype='datetime64[ns, UTC]') # doesn't work
The error:
TypeError Traceback (most recent call last)
<ipython-input-4-7101cf798aa3> in <module>()
----> 1 df = pd.DataFrame(array_dim2 , dtype='datetime64[ns, UTC]')
C:\D\Projects\Github\pandas\pandas\core\frame.py in __init__(self, data, index,
columns, dtype, copy)
252 else:
253 mgr = self._init_ndarray(data, index, columns, dtype=dty
pe,
--> 254 copy=copy)
255 elif isinstance(data, (list, types.GeneratorType)):
256 if isinstance(data, types.GeneratorType):
C:\D\Projects\Github\pandas\pandas\core\frame.py in _init_ndarray(self, values,
index, columns, dtype, copy)
412
413 if dtype is not None:
--> 414 if values.dtype != dtype:
415 try:
416 values = values.astype(dtype)
TypeError: data type not understood
Expected Output
In [5]: df = pd.DataFrame(array_dim2 , dtype='datetime64[ns, UTC]')
In [6]: df
Out[6]:
0 1
0 1970-01-01 00:00:00.000000000+00:00 1970-01-01 00:00:00.000000001+00:00
1 1970-01-01 00:00:00.000000002+00:00 1970-01-01 00:00:00.000000003+00:00
2 1970-01-01 00:00:00.000000004+00:00 1970-01-01 00:00:00.000000005+00:00
3 1970-01-01 00:00:00.000000006+00:00 1970-01-01 00:00:00.000000007+00:00
4 1970-01-01 00:00:00.000000008+00:00 1970-01-01 00:00:00.000000009+00:00
output of pd.show_versions()
python: 3.5.1.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
pandas: 0.18.0rc1+66.gce3ac93
nose: 1.3.7
pip: 8.0.2
setuptools: 19.2
Cython: 0.23.4
numpy: 1.10.1
scipy: None
statsmodels: None
xarray: None
IPython: 4.0.2
sphinx: 1.3.1
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: 2.3.3
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: None
lxml: 3.5.0
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8