Попробуйте использовать нарезку данных и div
:
import pandas as pd
import numpy as np
df1 = pd.DataFrame({'A':[1500,1700,2500,5700],
'B':[3000,2800,1804,7604],
'C':[2000,1500,1985,5485],
'D':[6500,6000,6289,18789]})
df2 = pd.DataFrame({'A':[4,10,13,27],
'B':[10,11,15,36],
'C':[25,80,33,138],
'D':[39,101,61,201]})
indx1 = pd.MultiIndex.from_product([['Total Sales'],['Vitoria','Rio De Janeiro','Sao Paulo','Total']])
indx2 = pd.MultiIndex.from_product([['Sales Count'],['Vitoria','Rio De Janeiro','Sao Paulo','Total']])
colind1 = pd.MultiIndex.from_product([['Month'],[1,2,3,'Total']])
df1.index = indx1
df1.columns = colind1
df1
df2.index = indx2
df2.columns = colind1
df_out = df1.loc['Total Sales'].div(df2.loc['Sales Count'])
df_out = df_out.iloc[:-1,:-1].assign(idx1='Sales Average')\
.set_index('idx1', append=True).swaplevel(0,1)
print(df_out)
Вывод:
Month
1 2 3
idx1
Sales Average Vitoria 375.000000 300.000000 80.000000
Rio De Janeiro 170.000000 254.545455 18.750000
Sao Paulo 192.307692 120.266667 60.151515