How can I fetch last value of column in dataframe.
close_value = from_csv['close_price'].tail(1)
Here is from_csv is my dataframe This gives me the needed output but in different format(given below)
Name: close_price, dtype: float64
1 0.985
I just want to store .985 in variable
from_csv.close_price.iloc[-1]
iloc
按位置选择, -1
表示最后一个位置。
Maybe this is not the most straightforward method, but for me the following seems to do what you want:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(4,4),columns=['a','b','c','d'])
df['a'].values[-1]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.