Pass the axis
option to the apply
function:
In [265]: f.apply(clean, axis=1)
Out[265]:
level1
item1 item2
0 1000 2000
1 2000 3000
2 3000 4000
When both axes have hierarchical indices here's a workaround:
In [316]: f.index = [[1,2,3],[1,2,3]]
In [317]: f
Out[317]:
level1
item1 item2
1 1 1,000 2,000
2 2 2,000 3,000
3 3 3,000 4,000
In [314]: f.apply(clean, axis=1).reindex(f.index)
Out[314]:
level1
item1 item2
1 1 1000 2000
2 2 2000 3000
3 3 3000 4000