Warm tip: This article is reproduced from serverfault.com, please click

Convert Pandas Dataframe value to float variable

发布于 2020-11-29 19:34:28

I have the following code to sort a python dataframe:

test2 = test.drop(['open', 'high', 'low', 'adjclose', 'volume', 'ticker'], axis=1)

The result of that is then:

                 close
2020-11-26  102.379997

Now I would just like to get the value "102.379997" into a float variable, so I can process it further, for example adding +1 etc.

However, I cannot find code to actually do this. Does anyone know how to do this?

Thank you very much in advance!

Questioner
particlezzzz
Viewed
1
particlezzzz 2020-11-30 03:47:07

Thanks to Nabil Daoud for answering this question, the way to do this is as following:

test2.iloc[0,0]