Skip to content

BUG: combine_first casts dtypes, pandas does not #7642

@Liquidmasl

Description

@Liquidmasl

Modin version checks

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

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

  • I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow this guide.)

Reproducible Example

Pandas

import pandas as pd
ddf1 = pd.DataFrame({"a":[1,2,3], "b":[4,5,6]})
ddf2 = pd.DataFrame({"a":[10,20,30], "c":[4,5,6]})
ddf1.combine_first(ddf2)
#     a  b  c
#  0  1  4  4
#  1  2  5  5
#  2  3  6  6

ddf1.combine_first(ddf2).dtypes
#  a    int64
#  b    int64
#  c    int64
#  dtype: object


Modin:

import modin.pandas as mpd
df1 = mpd.DataFrame({"a":[1,2,3], "b":[4,5,6]})
df2 = mpd.DataFrame({"a":[10,20,30], "c":[4,5,6]})

df1.combine_first(df2)
#      a  b    c
#  0   1  4  4.0
#  1   2  5  5.0
#  2   3  6  6.0

df1.combine_first(df2).dtypes
#  a       int64
#  b       int64
#  c    float64
#  dtype: object

Issue Description

int type should not be converted to float.

This is especially problematic with huge datasets, this explodes the amout of ram needed. And it a very hidden and weird issue.

Might be related to #5959, but that has not gotten any attention in a few years.

This is currently a real issue in our codebase.

Expected Behavior

Behave like pandas, column should stay int

Error Logs

No response

Installed Versions

INSTALLED VERSIONS

commit : 14680b3
python : 3.12.9
python-bits : 64
OS : Linux
OS-release : 6.8.0-52-generic
Version : #53~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 15 19:18:46 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
Modin dependencies

modin : 0.34.1
ray : 2.48.0
dask : None
distributed : None
pandas dependencies

pandas : 2.2.3
numpy : 2.2.6
pytz : 2025.2
dateutil : 2.9.0.post0
pip : None
Cython : None
sphinx : 8.2.3
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2025.3.2
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : 3.10.3
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 17.0.0
pyreadstat : None
pytest : 8.4.1
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.16.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Minor bugs or low-priority feature requestsbug 🦗Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions