Let's say that I have a multindex dataframe like the one below
In [221]: df
Out[221]:
first bar baz
second one two one two
A -1.089798 2.053026 0.470218 1.440740
B 0.488875 0.428836 1.413451 -0.683677
C -0.243064 -0.069446 -0.911166 0.47837
I would like to add a third and fourth column to each first level columns,'bar' and 'baz'.
I have been trying to use:
df[['bar','baz'],['third','forth']]=prices_df.apply(
lambda row: pd.Series(get_bond_metrics(row))
, axis=1)
But that is not the right way to make multiple assignments in a multi index dataframe.
Thank you