Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ Reshaping
- Bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
- Bug in :meth:`DataFrame.join` when a :class:`DataFrame` with a :class:`MultiIndex` would raise an ``AssertionError`` when :attr:`MultiIndex.names` contained ``None``. (:issue:`58721`)
- Bug in :meth:`DataFrame.merge` where merging on a column containing only ``NaN`` values resulted in an out-of-bounds array access (:issue:`59421`)
- Bug in :meth:`Series.combine_first` incorrectly replacing ``None`` entries with ``NaN`` (:issue:`58977`)
- Bug in :meth:`DataFrame.unstack` producing incorrect results when ``sort=False`` (:issue:`54987`, :issue:`55516`)
- Bug in :meth:`DataFrame.unstack` raising an error with indexes containing ``NaN`` with ``sort=False`` (:issue:`61221`)
- Bug in :meth:`DataFrame.merge` when merging two :class:`DataFrame` on ``intc`` or ``uintc`` types on Windows (:issue:`60091`, :issue:`58713`)
Expand Down
4 changes: 0 additions & 4 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
)
from pandas.core.dtypes.dtypes import (
ExtensionDtype,
SparseDtype,
)
from pandas.core.dtypes.generic import (
ABCDataFrame,
Expand Down Expand Up @@ -3254,9 +3253,6 @@ def combine_first(self, other) -> Series:
if self.dtype == other.dtype:
if self.index.equals(other.index):
return self.mask(self.isna(), other)
elif self._can_hold_na and not isinstance(self.dtype, SparseDtype):
this, other = self.align(other, join="outer")
return this.mask(this.isna(), other)

new_index = self.index.union(other.index)

Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/series/methods/test_combine_first.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,12 @@ def test_combine_mixed_timezone(self):
),
)
tm.assert_series_equal(result, expected)

def test_combine_first_none_not_nan(self):
# GH#58977
s1 = Series([None, None, None], index=["a", "b", "c"])
s2 = Series([None, None, None], index=["b", "c", "d"])

result = s1.combine_first(s2)
expected = Series([None] * 4, index=["a", "b", "c", "d"])
tm.assert_series_equal(result, expected)
Loading