Skip to content

Commit 0c74b1f

Browse files
committed
test(test_series): Simplify test_rename_with_multiindex.
1 parent cdf3013 commit 0c74b1f

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

pandas/tests/generic/test_series.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,22 @@ def finalize(self, other, method=None, **kwargs):
155155
# issue #43659
156156
def test_rename_with_multiindex(self):
157157
arrays = [
158-
["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"],
159-
["one", "two", "one", "two", "one", "two", "one", "two"],
158+
["bar", "baz", "baz", "foo", "qux"],
159+
["one", "one", "two", "two", "one"],
160160
]
161161

162-
tuples = list(zip(*arrays))
163-
index = MultiIndex.from_tuples(tuples, names=["first", "second"])
164-
s = Series(np.ones(8), index=index)
162+
index = MultiIndex.from_arrays(arrays, names=["first", "second"])
163+
s = Series(np.ones(5), index=index)
165164
result = s.rename(index={"one": "yes"}, level="second", errors="raise")
166165

167166
arrays_expected = [
168-
["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"],
169-
["yes", "two", "yes", "two", "yes", "two", "yes", "two"],
167+
["bar", "baz", "baz", "foo", "qux"],
168+
["yes", "yes", "two", "two", "yes"],
170169
]
171170

172-
tuples_expected = list(zip(*arrays_expected))
173-
index_expected = MultiIndex.from_tuples(
174-
tuples_expected, names=["first", "second"]
171+
index_expected = MultiIndex.from_arrays(
172+
arrays_expected, names=["first", "second"]
175173
)
176-
series_expected = Series(np.ones(8), index=index_expected)
174+
series_expected = Series(np.ones(5), index=index_expected)
177175

178176
assert result.equals(series_expected)

0 commit comments

Comments
 (0)