Skip to content

Commit df89c71

Browse files
committed
DOC: Add whatsnew note
1 parent 8ea1bdf commit df89c71

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -867,3 +867,4 @@ Other
867867
- :meth:`DataFrame.nlargest` and :meth:`DataFrame.nsmallest` now returns the correct n values when keep != 'all' also when tied on the first columns (:issue:`22752`)
868868
- :meth:`~pandas.io.formats.style.Styler.bar` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` and setting clipping range with ``vmin`` and ``vmax`` (:issue:`21548` and :issue:`21526`). ``NaN`` values are also handled properly.
869869
- Logical operations ``&, |, ^`` between :class:`Series` and :class:`Index` will no longer raise ``ValueError`` (:issue:`22092`)
870+
- Bug in :meth:`DataFrame.combine_first` in which column types were unexpectedly converted to float (:issue:`20699`)

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5077,7 +5077,7 @@ def combine(self, other, func, fill_value=None, overwrite=True):
50775077
# try to promote series, which is all NaN, as other_dtype.
50785078
new_dtype = other_dtype
50795079
try:
5080-
series = series.astype(new_dtype)
5080+
series = series.astype(new_dtype, copy=False)
50815081
except ValueError:
50825082
# e.g. new_dtype is integer types
50835083
pass

pandas/tests/frame/test_combine_concat.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from datetime import datetime
66

7+
import pytest
78
import numpy as np
89
from numpy import nan
910

@@ -750,13 +751,14 @@ def test_combine_first_int(self):
750751
tm.assert_frame_equal(res, df1)
751752
assert res['a'].dtype == 'int64'
752753

753-
def test_combine_first_with_asymmetric_other(self):
754-
# GH20699
755-
df1 = pd.DataFrame({'isInt': [1]})
754+
@pytest.mark.parametrize("val", [1, 1.0])
755+
def test_combine_first_with_asymmetric_other(self, val):
756+
# see gh-20699
757+
df1 = pd.DataFrame({'isNum': [val]})
756758
df2 = pd.DataFrame({'isBool': [True]})
757759

758760
res = df1.combine_first(df2)
759-
exp = pd.DataFrame({'isBool': [True], 'isInt': [1]})
761+
exp = pd.DataFrame({'isBool': [True], 'isNum': [val]})
760762

761763
tm.assert_frame_equal(res, exp)
762764

0 commit comments

Comments
 (0)