I want to perform complex operation over 3 excels. Firstly, I have filtered data in which user status is Enabled and then I will loop through other 2 excels to find out data corresponding to the Enable Users. I started looping one by one and saving in a list of tuples. I have tried using Normal Looping and itertuples() both but still its too slow. Is there any faster way to perform this operation-
from pandas import ExcelWriter
from pandas import ExcelFile
df = pd.read_excel('Enable-DisableUsersList.xlsx')
df2 = df[df.Status == '*ENABLED']
df1 = pd.read_excel('Excel1.xlsx')
df3 = pd.read_excel('Excel.xls2')
final_list = []
for ind1 in df1.index:
for ind2 in df2.index:
if(df1['USER PROFILE'][ind1] == df2['User ID'][ind2]):
for ind3 in df3.index:
if(df3['user profile'][ind3] == df2['User ID'][ind2]):
userprofile = df1['USER PROFILE'][ind1]
nameprofile = df1['NAME PROFILE'][ind1]
mainmenuno = df3['sysmenu option'][ind3]
mainmenu = df1['SUBMENU'][ind1]
mainmenudesc = df1['NAME SUBMENU'][ind1]
submenu = df1['OPTION'][ind1]
submenudesc = df1['NAME OF OPTION'][ind1]
status = df2['Status'][ind2]
list = (userprofile, nameprofile, mainmenuno, mainmenu,
mainmenudesc, submenu, submenudesc, status)
final_list.append(list)
# print(final_list)
print(final_list)````
I have used df.iterrows() instead of df.index also but still thats slow.