Skip to content

Commit

Permalink
TST: Added test for bug Reindexing pd.Float64Dtype() series gives run…
Browse files Browse the repository at this point in the history
…time warnings when passed to np.log (pandas-dev#47087)

* TST: For issue GH 47055

* Changes according to pre-commit

* Made changes according to review
  • Loading branch information
MiloniAtal authored and yehoshuadimarsky committed Jul 13, 2022
1 parent 883adba commit 9221880
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pandas/tests/series/methods/test_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import pytest

from pandas import (
NA,
Categorical,
Float64Dtype,
Index,
MultiIndex,
NaT,
Expand Down Expand Up @@ -408,3 +410,16 @@ def test_reindex_missing_category():
msg = r"Cannot setitem on a Categorical with a new category \(-1\)"
with pytest.raises(TypeError, match=msg):
ser.reindex([1, 2, 3, 4, 5], fill_value=-1)


def test_reindexing_with_float64_NA_log():
# GH 47055
s = Series([1.0, NA], dtype=Float64Dtype())
s_reindex = s.reindex(range(3))
result = s_reindex.values._data
expected = np.array([1, np.NaN, np.NaN])
tm.assert_numpy_array_equal(result, expected)
with tm.assert_produces_warning(None):
result_log = np.log(s_reindex)
expected_log = Series([0, np.NaN, np.NaN], dtype=Float64Dtype())
tm.assert_series_equal(result_log, expected_log)

0 comments on commit 9221880

Please sign in to comment.