Skip to content
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

BUG: object of type 'int' has no len() in from_dict function #46092

Closed
2 of 3 tasks
andreapi87 opened this issue Feb 21, 2022 · 2 comments
Closed
2 of 3 tasks

BUG: object of type 'int' has no len() in from_dict function #46092

andreapi87 opened this issue Feb 21, 2022 · 2 comments
Labels
Bug Constructors Series/DataFrame/Index/pd.array Constructors Docs Needs Triage Issue that has not been reviewed by a pandas team member Usage Question

Comments

@andreapi87
Copy link

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

d={ 'a': [3,2],'b':2}
pandas.DataFrame.from_dict(d,orient='index')

Issue Description

d={ 'b':2,'a': [3,2],}
pandas.DataFrame.from_dict(d,orient='index')

gives no problem , but if i change the dict order I get I get object of type 'int' has no len()

Expected Behavior

d={ 'b':2,'a': [3,2],}
pandas.DataFrame.from_dict(d,orient='index')

Installed Versions

INSTALLED VERSIONS

commit : 7d32926
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-26-generic
Version : #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : it_IT.UTF-8
LOCALE : it_IT.UTF-8

pandas : 1.2.2
numpy : 1.19.2
pytz : 2021.1
dateutil : 2.8.1
pip : 22.0.2
setuptools : 49.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
numba : None

@andreapi87 andreapi87 added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 21, 2022
@phofl
Copy link
Member

phofl commented Feb 21, 2022

According to the docs this is not supported. The values have to be either an array-like or a dict, not a scalar.

@phofl phofl added Constructors Series/DataFrame/Index/pd.array Constructors Docs Usage Question labels Feb 21, 2022
@mroeschke
Copy link
Member

Thanks for the report, but since this is documented behavior, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Constructors Series/DataFrame/Index/pd.array Constructors Docs Needs Triage Issue that has not been reviewed by a pandas team member Usage Question
Projects
None yet
Development

No branches or pull requests

3 participants