From 957f38fa2eafb2334cf505391fa7f523fbcc6fbe Mon Sep 17 00:00:00 2001 From: Kyungtae Kim Date: Fri, 1 Nov 2024 22:51:56 +0900 Subject: [PATCH] BUG: fix #60128 BUG: Series.combine_first loss of precision - Issue: There was int64->float64->int64 conversions - Fix: Carry out the operation without passing through float64 --- pandas/core/frame.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 1b47002e72fc6..4f3eadda318ab 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8640,7 +8640,10 @@ def combine( """ other_idxlen = len(other.index) # save for compare - this, other = self.align(other) + fill_value_for_align = None + if all(self.dtypes.eq(np.int64)) and all(other.dtypes.eq(np.int64)): + fill_value_for_align = 0 + this, other = self.align(other, fill_value=fill_value_for_align) new_index = this.index if other.empty and len(new_index) == len(self.index):