I am new to python Pandas and I am calculating the RSI Indicator via Python Pandas. I am getting an index series from type float64.
0 100
2 200
I just need always the last value e.g. 200 but don't know how to get this. I tried to access it via index but no chance
def get_rsi(series, period):
delta = series.diff().dropna()
u = delta * 0
d = u.copy()
u[delta > 0] = delta[delta > 0]
d[delta < 0] = -delta[delta < 0]
u[u.index[period-1]] = np.mean( u[:period] ) #first value is sum of avg gains
u = u.drop(u.index[:(period-1)])
d[d.index[period-1]] = np.mean( d[:period] ) #first value is sum of avg losses
d = d.drop(d.index[:(period-1)])
rs = pd.DataFrame.ewm(u, com=period-1, adjust=False).mean() / \
pd.DataFrame.ewm(d, com=period-1, adjust=False).mean()
output = 100 - 100 / (1 rs)
return output
Trying to access
data = pd.Series(closes)
print(data[0]) // no values getting only the float64
CodePudding user response:
If you want to access values of a pandas series you can use
data = pd.Series(closes)
print(data.values[0])