Skip to content

Commit ff8e1bb

Browse files
committed
BUG: Ignore division by 0 when merging empty dataframes (pandas-dev#17776)
1 parent 7e159ae commit ff8e1bb

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,7 @@ Reshaping
10021002
- Bug in :func:`concat` where order of result index was unpredictable if it contained non-comparable elements (:issue:`17344`)
10031003
- Fixes regression when sorting by multiple columns on a ``datetime64`` dtype ``Series`` with ``NaT`` values (:issue:`16836`)
10041004
- Bug in :fun:`pivot_table` where the result's columns did not preserve the categorical dtype of ``columns`` when ``dropna`` was ``False`` (:issue:`17842`)
1005+
- Bug in merging two empty dataframes, which raised a division by zero warning (:issue:`17776`)
10051006

10061007
Numeric
10071008
^^^^^^^

pandas/core/reshape/merge.py

+2
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,7 @@ def _sort_labels(uniques, left, right):
15141514

15151515

15161516
def _get_join_keys(llab, rlab, shape, sort):
1517+
np.seterr(divide='ignore')
15171518

15181519
# how many levels can be done without overflow
15191520
pred = lambda i: not is_int64_overflow_possible(shape[:i])
@@ -1528,6 +1529,7 @@ def _get_join_keys(llab, rlab, shape, sort):
15281529
stride //= shape[i]
15291530
lkey += llab[i] * stride
15301531
rkey += rlab[i] * stride
1532+
np.seterr(divide='warn')
15311533

15321534
if nlev == len(shape): # all done!
15331535
return lkey, rkey

0 commit comments

Comments
 (0)