Skip to content

REF: misplaces Series.where, Series.rename tests #32969

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 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions pandas/tests/series/indexing/test_alter_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,16 +479,6 @@ def test_reindex_empty_series_tz_dtype():
tm.assert_equal(result, expected)


def test_rename():
# GH 17407
s = Series(range(1, 6), index=pd.Index(range(2, 7), name="IntIndex"))
result = s.rename(str)
expected = s.rename(lambda i: str(i))
tm.assert_series_equal(result, expected)

assert result.name == expected.name


@pytest.mark.parametrize(
"data, index, drop_labels, axis, expected_data, expected_index",
[
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/series/indexing/test_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,11 @@ def test_where_dt_tz_values(tz_naive_fixture):
pd.DatetimeIndex(["20150101", "20150102", "20160516"], tz=tz_naive_fixture)
)
tm.assert_series_equal(exp, result)


def test_where_sparse():
# GH#17198 make sure we dont get an AttributeError for sp_index
ser = pd.Series(pd.arrays.SparseArray([1, 2]))
result = ser.where(ser >= 2, 0)
expected = pd.Series(pd.arrays.SparseArray([0, 2]))
tm.assert_series_equal(result, expected)
9 changes: 9 additions & 0 deletions pandas/tests/series/methods/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ class MyIndexer:
s = Series([1, 2, 3])
s.rename(ix, inplace=True)
assert s.name is ix

def test_rename_callable(self):
# GH 17407
s = Series(range(1, 6), index=Index(range(2, 7), name="IntIndex"))
result = s.rename(str)
expected = s.rename(lambda i: str(i))
tm.assert_series_equal(result, expected)

assert result.name == expected.name
7 changes: 0 additions & 7 deletions pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,6 @@ def test_fillna_consistency(self):
s2[1] = "foo"
tm.assert_series_equal(s2, expected)

def test_where_sparse(self):
# GH#17198 make sure we dont get an AttributeError for sp_index
ser = pd.Series(pd.arrays.SparseArray([1, 2]))
result = ser.where(ser >= 2, 0)
expected = pd.Series(pd.arrays.SparseArray([0, 2]))
tm.assert_series_equal(result, expected)

def test_datetime64tz_fillna_round_issue(self):
# GH 14872

Expand Down