我想在multiindex列数据帧的第二级添加一列.
In [151]: df
Out[151]:
first bar baz
second one two one two
A 0.487880 -0.487661 -1.030176 0.100813
B 0.267913 1.918923 0.132791 0.178503
C 1.550526 -0.312235 -1.177689 -0.081596
Run Code Online (Sandbox Code Playgroud)
通常的直接分配技巧不起作用:
In [152]: df['bar']['three'] = [0, 1, 2]
In [153]: df
Out[153]:
first bar baz
second one two one two
A 0.487880 -0.487661 -1.030176 0.100813
B 0.267913 1.918923 0.132791 0.178503
C 1.550526 -0.312235 -1.177689 -0.081596
Run Code Online (Sandbox Code Playgroud)
如何将第三行添加到"bar"下?