I'm trying to apply a simple function on a pd.DataFrame but I need the index of each element while applying.
Consider this DataFrame:
| CLM_1 | CLM_1 | |
|---|---|---|
| A | foo | bar |
| B | bar | foo |
| C | bar | foo |
and I want a pd.Series as result like so:
A 'A'
B 'B'
C 'D'
Length: 3, dtype: object
My approach:
I used df.apply(lambda row: row.index, axis=1) which obviously didn't work.