I have a set of tab delimited files that I have to go through read them, use them as pandas dataframe, do a whole bunch of operations on them and then merge them back to one excel file, the code is too long so I am going to go through the problematic part of it
The tab files that I am parsing contains all the same number of rows 2177
When I read these files I am indexing by the first 2 columns of type (string, int)
df = df.set_index(['id', 'coord'])
data = OrderedDict()
#data will contain all the information I am writing to excel
data[filename_id] = df
one of the procedures I am doing needs access to each row of data[sample_id] which contains dataframe of mixed types indexed with the columns 'id' and 'coord', like this
sample_row = data[sample].ix[index]
my index being ('id','coord')
If I am treating a subset of the file everything works great, but If I read the entire files with 2177 lines I end up having this error message
KeyError: 'Key length (2) was greater than MultiIndex lexsort depth (0)'
I searched over SO and everywhere and it seems that this is an issue of sorting the index, but I dont understand why using an unsorted subset do not cause the problem
Any idea on how I can get this sorted out ?
Thanks