Skip to content

Can't initialise DataFrame with ExtensionDtype, but can do so for Series #30280

New issue

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

Closed
MarcoGorelli opened this issue Dec 15, 2019 · 0 comments · Fixed by #30284
Closed

Can't initialise DataFrame with ExtensionDtype, but can do so for Series #30280

MarcoGorelli opened this issue Dec 15, 2019 · 0 comments · Fixed by #30284
Labels
Constructors Series/DataFrame/Index/pd.array Constructors ExtensionArray Extending pandas with custom dtypes or arrays.
Milestone

Comments

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Dec 15, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
import pytz

temp = pd.Series([pd.Timestamp("2019-07-19 07:04:57+0100", tz=pytz.FixedOffset(60))])
pd.Series(["2019-06-19 07:04:57"], dtype=temp.dtype)  # works
pd.DataFrame(["2019-06-19 07:04:57"]).astype(temp.dtype)  # works
pd.DataFrame(["2019-06-19 07:04:57"], dtype=temp.dtype)  # fails

Problem description

I get the following error:

ValueError: failed to cast to 'datetime64[ns, pytz.FixedOffset(60)]' (Exception was: data type not understood)

Expected Output

I would have expected the same output as I got in the first two examples above labelled #works.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-70-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0.25.3
numpy : 1.17.4
pytz : 2019.3
dateutil : 2.8.0
pip : 19.3.1
setuptools : 41.4.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.9.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None

@jorisvandenbossche jorisvandenbossche added Constructors Series/DataFrame/Index/pd.array Constructors ExtensionArray Extending pandas with custom dtypes or arrays. labels Dec 15, 2019
@jreback jreback added this to the 1.0 milestone Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constructors Series/DataFrame/Index/pd.array Constructors ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants