The error is when you create A
with
columns = [['att1', 'att2']]
If you print A.columns
you will get:
MultiIndex([('att1',),
('att2',),
( 'idx',)],
)
So 'idx'
is not really in your column for you to set index. Now, this would work:
A.set_index(('idx',))
and give:
att1 att2
(idx,)
a 1 2
b 1 3
c 4 6
However, you should fix your creation of A
with just:
columns = ['att1', 'att2']
CLICK HERE to find out more related problems solutions.