You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
df1 has columns [0, 1] with the array exploded
df2 has only one column(0) with the array as value
Expected Behavior
Expected the order of the items of the dictionary to not impact on the result of the data frame.
Since it's possible to pass a combination of scalars and lists, I would expect it to work the same regardless the dict items order.
Installed Versions
INSTALLED VERSIONS
commit : 8dab54d
python : 3.11.0.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-56-generic
Version : #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
The documentation states that pd.DataFrame.from_dict is to be used to "Construct DataFrame from dict of array-like or dicts". A string is not considered array-like in this case.
I agree those two operation should give the same rows, so this is a bug.
More generally, we normally treat listlikes in DataFrame/series constructors and I think we should to that here too, though that may be an enhancement, so goes beyond this concrete issue. Also I'd expect a scalar to explode rowwise , so I'd actually expect df1 to be:
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
Issue Description
df1 has columns [0, 1] with the array exploded
df2 has only one column(0) with the array as value
Expected Behavior
Expected the order of the items of the dictionary to not impact on the result of the data frame.
Since it's possible to pass a combination of scalars and lists, I would expect it to work the same regardless the dict items order.
Installed Versions
INSTALLED VERSIONS
commit : 8dab54d
python : 3.11.0.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.0-56-generic
Version : #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.2
numpy : 1.24.1
pytz : 2022.7
dateutil : 2.8.2
setuptools : 65.6.3
pip : 22.3.1
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 : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: