Skip to content

Commit 1cf86a1

Browse files
committed
BUG: iloc fails with non lex-sorted MultiIndex #13797
apply pep8radius to tests/test_multilevel.py
1 parent a23c736 commit 1cf86a1

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

pandas/tests/test_multilevel.py

+18-17
Original file line numberDiff line numberDiff line change
@@ -2424,26 +2424,27 @@ def test_iloc_mi(self):
24242424
# GH 13797
24252425
# Test if iloc can handle integer locations in MultiIndexed DataFrame
24262426

2427-
data =[
2428-
['str00', 'str01'],
2429-
['str10', 'str11'],
2430-
['str20', 'srt21'],
2431-
['str30', 'str31'],
2432-
['str40', 'str41']
2433-
]
2434-
2435-
mi= pd.MultiIndex.from_tuples(
2436-
[('CC','A'),
2437-
('CC','B'),
2438-
('CC','B'),
2439-
('BB','a'),
2440-
('BB','b')
2441-
])
2427+
data = [
2428+
['str00', 'str01'],
2429+
['str10', 'str11'],
2430+
['str20', 'srt21'],
2431+
['str30', 'str31'],
2432+
['str40', 'str41']
2433+
]
2434+
2435+
mi = pd.MultiIndex.from_tuples(
2436+
[('CC', 'A'),
2437+
('CC', 'B'),
2438+
('CC', 'B'),
2439+
('BB', 'a'),
2440+
('BB', 'b')
2441+
])
24422442

24432443
ans = pd.DataFrame(data)
2444-
df_mi = pd.DataFrame(data, index = mi)
2444+
df_mi = pd.DataFrame(data, index=mi)
24452445

2446-
res = pd.DataFrame([[df_mi.iloc[r,c] for c in range(2)] for r in range(5)])
2446+
res = pd.DataFrame([[df_mi.iloc[r, c] for c in range(2)]
2447+
for r in range(5)])
24472448

24482449
assert_frame_equal(res, ans)
24492450

0 commit comments

Comments
 (0)