Reputation: 3529
I am currently working on a function for: dataframe.apply(function, axis=1).
I need to reference the value of the index (ie, 0, 1, 2 etc, whatever the index is in the row that's passed above).
def function(row):
whatstheindex = row.index?
return whatstheindex
I can't figure out to reference that though. I've tried row['INDEXNAME'], I've tried using:
float(row.index.get_loc(row.loc[:,:,row['ROWVALUE']].index[0]))
but ROWVALUE is non-unique, and I think its returning more than one index? The error I got was:
IndexingError: ('Too many indexers', u'occurred at index XYZ')
Upvotes: 0
Views: 60
Reputation: 123
Have you tried row.name
? The rows are pandas series in the apply function
Upvotes: 1