BUG: Series
type as first item from list ,in new Dataframe disallows the assignment of dicts
with same stracture
#56322
Labels
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
Description
This bug occurs if the Dataframe is initialized by passing an array with objects and the first item MUST be a
Series
object as shown in the example above.Weird Observation
If we flip the order of the object in the array so that the
dict
object is first then the expected behaviour occurs , where the dataframe is created successfully with both object inside. example code and output:output :
Expected Behavior
Expected behaviour
a Dataframe with both objects (that have the same fields) is created
Actual
the program crashes with following stack trace:
Installed Versions
INSTALLED VERSIONS
commit : 2a953cf
python : 3.10.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.90.1-microsoft-standard-WSL2
Version : #1 SMP Fri Jan 27 02:56:13 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.3
numpy : 1.26.1
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 59.6.0
pip : 22.0.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.16.1
pandas_datareader : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.1
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
Process finished with exit code 0
The text was updated successfully, but these errors were encountered: