Description
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
import warnings
import pandas as pd
with warnings.catch_warnings(record=True) as w:
df = pd.DataFrame({'A': [1]})
df2 = pd.DataFrame({'A': [None]})
df['A'].combine_first(df2['A'])
assert len(w) == 1
assert w[0].category.__name__ == 'FutureWarning'
assert x.message.args == ('The behavior of array concatenation with empty entries is deprecated. In a future version, this will no longer exclude empty items when determining the result dtype. To retain the old behavior, exclude the empty entries before the concat operation.',)
Issue Description
The concat
function in pandas is designed to emit a FutureWarning
when attempting to concatenate an empty DataFrame, which is a logical consequence of its intended behavior. However, there is an inconsistency with the combine_first
method. It occasionally generates the same FutureWarning
associated with concatenation, in a manner that may seem perplexing, even when both DataFrames involved in the operation are clearly non-empty. This anomaly can present challenges in preemptively suppressing the warning within one's code without affecting the overall functionality.
Expected Behavior
Avoid confusing warnings
Installed Versions
INSTALLED VERSIONS
commit : fd3f571
python : 3.11.6.final.0
python-bits : 64
OS : Darwin
OS-release : 21.6.0
Version : Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US
LOCALE : en_US.UTF-8
pandas : 2.2.0
numpy : 1.25.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 67.4.0
pip : 23.0.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.12.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2023.9.2
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None