@@ -155,24 +155,22 @@ def finalize(self, other, method=None, **kwargs):
155
155
# issue #43659
156
156
def test_rename_with_multiindex (self ):
157
157
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" ],
160
160
]
161
161
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 )
165
164
result = s .rename (index = {"one" : "yes" }, level = "second" , errors = "raise" )
166
165
167
166
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" ],
170
169
]
171
170
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" ]
175
173
)
176
- series_expected = Series (np .ones (8 ), index = index_expected )
174
+ series_expected = Series (np .ones (5 ), index = index_expected )
177
175
178
176
assert result .equals (series_expected )
0 commit comments