I have a Pandas DataFrame
(created from an excel file) in which I want to look into a row, ignore nan
values, and get the position of the remaining elements. So I'm doing:
lines = df.iloc[16, :].dropna()
print(lines)
Which yields:
2 10
6 11
10 12
14 13
18 14
Where the first column is the automatic indexing that Pandas gives to each row in my excel. I want a list those index, position = [2, 6, 10, 14, 18]
.
How can I extract those indices? I tried with lines.tolist()
but it only gets the values without the position/index.