xxxxxxxxxx
df.set_index(['col1', 'col2']) # Set/Create multi-level index
df.loc[[('col1val1','col2val1'), ('col1val2','col2val2')]] # Subsetting using multi-level index
xxxxxxxxxx
#iterate only through rows with missing LoanAmount
for i,row in data.loc[data['LoanAmount'].isnull(),:].iterrows():
ind = tuple([row['Gender'],row['Married'],row['Self_Employed']])
data.loc[i,'LoanAmount'] = impute_grps.loc[ind].values[0]
#Now check the #missing values again to confirm:
print data.apply(num_missing, axis=0)