JOHN
JOHN

Reputation: 1521

How to extract value from a dataframe

enter image description here

How can I extract the last value, 102.584855? I have tried df[-1:].iloc[0] but it will return the 20 as well. Howe to get only 102.58485? Thanks!

Upvotes: 1

Views: 114

Answers (1)

unutbu
unutbu

Reputation: 880927

You could use: df.iloc[-1, 0]. When 2 indexers are passed to iloc, the first indicates the index of the rows, the second the index of the columns. So df.iloc[-1, 0] selects the value in the last row and first column.

Alternatively, df[-1:].iloc[0].item() would also work, but is less efficient.

Upvotes: 4

Related Questions