I use three columns from the data frame for indexing:
df = df.set_index(['col1','col2','col3'])
Then I try to get the row that corresponds to a particular index. I tried many different ways:
x = df.loc[(123,456,789)]
x = df.ix[(123,456,789)]
x = df.loc[123,456,789]
x = df.ix[123,456,789]
None of these options works. The error message that I get is:
raise e1
KeyError: 'MultiIndex lexsort depth 0, key was length 3'
I checked if the used value of index exists:
inds = []
for ind in df.index:
inds.append(ind)
if (123,456,789) in inds:
print 'in'
else:
print 'out'
As the result I get in (so, this used value of index exists). What am I doing wrong?