Skip to content

TST: Added test for bug Reindexing pd.Float64Dtype() series gives runtime warnings when passed to np.log #47087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 8, 2022
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)