BUG: Construction of DataFrame works with empty list but not empty array #46822
Labels
API - Consistency
Internal Consistency of API/Behavior
Bug
Constructors
Series/DataFrame/Index/pd.array Constructors
DataFrame
DataFrame data structure
Error Reporting
Incorrect or improved errors from pandas
Testing
pandas testing functions or related to the test suite
Milestone
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
Constructing an empty dataframe with an empty list works fine, but giving an empty numpy array, which intuitively should behave the same as with an empty list, results in a mysterious
ValueError: Empty data passed with indices specified.
Expected Behavior
Should create an empty dataframe with whatever columns listed.
Installed Versions
INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.9.7.final.0
python-bits : 64
OS : Darwin
OS-release : 21.4.0
Version : Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.2
numpy : 1.21.4
pytz : 2021.1
dateutil : 2.8.2
pip : 21.3.1
setuptools : 57.4.0
Cython : 0.29.24
pytest : 6.2.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.1
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.25.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : 2.0.1
matplotlib : 3.4.3
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.7
pandas_gbq : 0.15.0
pyarrow : 5.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
snappy : None
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: