I have a dataframe which is multi-index and passing a list or a string to the loc accessor doesn't work.
My dataframe has two indexes : Name_1, Name_2
.
Let tempList=[ 'Marco John' , Peter Dorset']
data.loc['Marco John','Peter Dorset']['Combined Salary']
works
data.loc[tempList[0],tempList[1]]['Combined Salary']
works
data.loc[tempList]['Combined Salary']
doesn't work?
tempstring = tempList[0]+','+templist[1]
data.loc[tempstring]['Combined Salary']
doesn't work?
Can anyone tell me what's wrong with passing a string to the loc accessor?