Description
Code Sample, a copy-pastable example if possible
from pandas import Categorical
Categorical(['2015-01-01']).astype('datetime64[ns]') # works
Categorical(['2015-01-01']).astype('datetime64[ns, MET]') # fails
This is because the astype
method returns
np.array(self, dtype=dtype, copy=copy)
, and numpy
arrays don't handle this dtype.
Is this expected behaviour?
Output of pd.show_versions()
pandas : 0.25.1
numpy : 1.16.4
pytz : 2019.2
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : None
pytest : 5.0.1
hypothesis : None
sphinx : 2.2.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.8.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.13.0
pytables : None
s3fs : None
scipy : 1.2.1
sqlalchemy : None
tables : 3.5.2
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None