We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This works with series
In [1]: import pandas as pd In [2]: pd.Series(index=[0, 1], dtype='datetime64[ns, UTC]') Out[2]: 0 NaT 1 NaT dtype: datetime64[ns, UTC]
but not DataFrames
In [3]: pd.DataFrame(index=[0, 1], columns=[0], dtype='datetime64[ns, UTC]')
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-7b2502f909f5> in <module>() ----> 1 pd.DataFrame(index=[0, 1], columns=[0], dtype='datetime64[ns, UTC]') ~/sandbox/pandas/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy) 348 dtype=dtype, copy=copy) 349 elif isinstance(data, dict): --> 350 mgr = self._init_dict(data, index, columns, dtype=dtype) 351 elif isinstance(data, ma.MaskedArray): 352 import numpy.ma.mrecords as mrecords ~/sandbox/pandas/pandas/core/frame.py in _init_dict(self, data, index, columns, dtype) 445 # no obvious "empty" int column 446 if missing.any() and not is_integer_dtype(dtype): --> 447 if dtype is None or np.issubdtype(dtype, np.flexible): 448 # 1783 449 nan_dtype = object ~/Envs/pandas-dev/lib/python3.6/site-packages/numpy/numpy/core/numerictypes.py in issubdtype(arg1, arg2) 713 """ 714 if not issubclass_(arg1, generic): --> 715 arg1 = dtype(arg1).type 716 if not issubclass_(arg2, generic): 717 arg2_orig = arg2 TypeError: data type not understood
same w/ a dict dtype={0: 'datetime64[ns, UTC]'), and with the actual dtype as well.
dtype={0: 'datetime64[ns, UTC]')
In [5]: pd.DataFrame(index=[0, 1], columns=[0], dtype={0: pd.api.types.pandas_dtype('datetime64[ns, UTC]')}) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-5-3b35d67fd1e7> in <module>() ----> 1 pd.DataFrame(index=[0, 1], columns=[0], dtype={0: pd.api.types.pandas_dtype('datetime64[ns, UTC]')}) ~/sandbox/pandas/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy) 339 data = {} 340 if dtype is not None: --> 341 dtype = self._validate_dtype(dtype) 342 343 if isinstance(data, DataFrame): ~/sandbox/pandas/pandas/core/generic.py in _validate_dtype(self, dtype) 166 167 if dtype is not None: --> 168 dtype = pandas_dtype(dtype) 169 170 # a compound dtype ~/sandbox/pandas/pandas/core/dtypes/common.py in pandas_dtype(dtype) 2011 2012 try: -> 2013 npdtype = np.dtype(dtype) 2014 except (TypeError, ValueError): 2015 raise ~/Envs/pandas-dev/lib/python3.6/site-packages/numpy/numpy/core/_internal.py in _usefields(adict, align) 60 names = None 61 if names is None: ---> 62 names, formats, offsets, titles = _makenames_list(adict, align) 63 else: 64 formats = [] ~/Envs/pandas-dev/lib/python3.6/site-packages/numpy/numpy/core/_internal.py in _makenames_list(adict, align) 28 for fname in fnames: 29 obj = adict[fname] ---> 30 n = len(obj) 31 if not isinstance(obj, tuple) or n not in [2, 3]: 32 raise ValueError("entry not a 2- or 3- tuple") TypeError: object of type 'DatetimeTZDtype' has no len()
The text was updated successfully, but these errors were encountered:
Think this is a dupe of #12513
Sorry, something went wrong.
Indeed, missed that in my search. Thanks.
No branches or pull requests
This works with series
but not DataFrames
same w/ a dict
dtype={0: 'datetime64[ns, UTC]')
, and with the actual dtype as well.The text was updated successfully, but these errors were encountered: