Skip to content

Commit d3d1bdc

Browse files
authored
TST: Added test for bug Reindexing pd.Float64Dtype() series gives runtime warnings when passed to np.log (#47087)
* TST: For issue GH 47055 * Changes according to pre-commit * Made changes according to review
1 parent 730b307 commit d3d1bdc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/series/methods/test_reindex.py

+15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import pytest
33

44
from pandas import (
5+
NA,
56
Categorical,
7+
Float64Dtype,
68
Index,
79
MultiIndex,
810
NaT,
@@ -408,3 +410,16 @@ def test_reindex_missing_category():
408410
msg = r"Cannot setitem on a Categorical with a new category \(-1\)"
409411
with pytest.raises(TypeError, match=msg):
410412
ser.reindex([1, 2, 3, 4, 5], fill_value=-1)
413+
414+
415+
def test_reindexing_with_float64_NA_log():
416+
# GH 47055
417+
s = Series([1.0, NA], dtype=Float64Dtype())
418+
s_reindex = s.reindex(range(3))
419+
result = s_reindex.values._data
420+
expected = np.array([1, np.NaN, np.NaN])
421+
tm.assert_numpy_array_equal(result, expected)
422+
with tm.assert_produces_warning(None):
423+
result_log = np.log(s_reindex)
424+
expected_log = Series([0, np.NaN, np.NaN], dtype=Float64Dtype())
425+
tm.assert_series_equal(result_log, expected_log)

0 commit comments

Comments
 (0)