данные 1
import pandas as pd
#data 01
df_products = pd.DataFrame([{'Product ID' : 4109,'Price' : 5.0,'Product' : 'Sushi Roll'},
{'Product ID' : 1412,'Price' : 0.5,'Product' : 'Egg'},
{'Product ID' : 8931,'Price' : 1.5,'Product' : 'Bagel'}])
df_products = df_products.set_index('Product ID')
data2
df_invoices = pd.DataFrame([{'Customer' : 'Ali' , 'Product ID' : 4109 , 'Quantity' : 1},
{'Customer' : 'Eric' , 'Product ID' : 1412 , 'Quantity' : 12},
{'Customer' : 'Ande' , 'Product ID' : 8931 , 'Quantity' : 6},
{'Customer' : 'Sam' , 'Product ID' : 4109 , 'Quantity' : 2}])
df_invoices = df_invoices.set_index('Product ID')
объединенные данные
df_overall = pd.merge(df_products , df_invoices , how='outer' , left_index =
True ,right_index = True)
новый фрейм данных с уплаченной суммой
df_total = df_overall['Price'] * df_overall['Quantity']
Я хочу показать все кадры данных с результатом!
но эта последняя строка не работает правильно!
df_result = pd.merge(df_overall , df_total , how='outer' ,
left_index = True , right_index = True)