-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Setting types on DataFrame constructor not working, while setting them after construction does. #21445
Comments
Looks like its just an issue with the constructor. Investigation and PRs welcome! |
@gfyoung @WillAyd @acburigo I would like to draw your attention to the Lines 249 to 273 in 9e982e1
|
Hmm good point @uds5501 . I didn't even look at that to be honest. We do allow dicts for
|
@WillAyd In my opinion , raising a more informative message would be a quicker path (not sure about the best though) and work upon introducing a dictionary unpacker in with constructor in the future? |
I don't disagree, but I suppose if the documentation was wrong (i.e. it looks like the code should allow for this type of construction) then I would lean towards the latter. It would also be entirely reasonable for one PR to have a better error message (this would be easier as you mentioned) and then have a separate issue / PR to enhance this and allow more than one dtype, if someone wants to make that contribution |
@WillAyd Well, I looked through the documentation and could not see a single instance where it may indicate that such multi data type construction is allowed. I would look at it a bit thoroughly again and will file a PR for putting in better error message if couldn't get on |
there is an open issue for this already |
I think I found that #4464 - closing this in favor of that |
Code Sample, a copy-pastable example if possible
Problem description
Why does setting types on constructor does not work, when setting them after construction is OK (see code)?
Expected Output
See code above.
Output of
pd.show_versions()
Happens with pandas
0.22.00
and0.23.00
(not sure about other versions).[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.22.0
pytest: None
pip: 10.0.1
setuptools: 39.0.1
Cython: None
numpy: 1.14.2
scipy: 1.0.1
pyarrow: None
xarray: None
IPython: 6.3.1
sphinx: None
patsy: None
dateutil: 2.7.2
pytz: 2018.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: