Image shows a pandas dataframe
import pandas as pd
import numpy as np
file = '/Dummy.xlsx'
Customer = pd.read_excel(file, sheet_name=0)
Items = pd.read_excel(file, sheet_name=1)
Commission = pd.read_excel(file, sheet_name=2)
Price = pd.read_excel(file, sheet_name=3)
Sheet1 = pd.read_excel(file, sheet_name=4)
Inner_join = pd.merge(Price,Sheet1,on = 'Item_ID', how='inner')
Inner_join = pd.merge(Price, Sheet1,on = 'Item_ID', how='inner').merge(Commission, on = 'Commission_ID')
joined_table = pd.merge(Inner_join, Customer, right_on = 'Customer_ID', left_on = 'Customer_ID_x', how = 'inner')
final_table = joined_table[['Date','Customer_Name', 'Customer_ID','Item_Name', 'Commission', 'Qty','Base_Price','Rate']]
calculated_commission = final_table[final_table.loc[:,'Base_Price'] < final_table.loc[:, 'Rate']]
calculated_commission['final_com'] = cal_com.loc[:, 'Qty'] * cal_com.loc[:, 'Commission']][2]
customers = calculated_commission['Customer_Name'].unique()
for i in customers:
a = calculated_commission[calculated_commission['Customer_Name'].str.match(i)]
a.to_excel(i+'.xlsx')
I'm trying to iterate over unique customer names and write them in different excel files and name that with the same name.
It created both files but writes data only on the second file which is 'Chef Themiya'
access below link for the dataset:
https://drive.google.com/file/d/1VWc_WoN1nTWiDKK1YDtIXtzaAGdgbfpl/view?usp=sharing
Please help