I have created a dataframe with multi index columns from lists using:
trans = ['Scale Up', 'Scale Down', 'U']
sources = ['P1', 'P2']
cols = ['date', 'sec']
index = pd.MultiIndex.from_product([trans, sources, cols])
df=pd.DataFrame(columns=index)
df is the dataframe I am supposed to fill, just for printing and understanding the columns I use:
index.to_frame().transpose()
for each trans and source I want to fill date and sec based on another data frame new_positions:
my_data=new_positions.loc[((new_positions['trans']=='Scale Up') & (new_positions['source'] == 'P1'))].sort_values(['score']).tail(10)[['date', 'sec']].copy()
the whole dataframe (sec and date) is supposed to be filled with a loop over level0 and 1. Here is how I want to fill sec and date for level0='Scale Up' and level1='P1'

