Stock Prediction Us...
 
Notifications
Clear all

Stock Prediction Using LSTM (3. Feature Engineering)

3 Posts
2 Users
0 Reactions
30 Views
0
Topic starter

Hello,
When I run the command :

df1['MA_5'] = df1.rolling(5).mean()
df1

The program announces an error and I have to remove df1 and put it in a new cell and it works. I don't understand this error. Please help me with more details.
Thank you for your help.

 

 

 

 

IMG 1866 rathank.com Mohaiminul - Team Rathan 10/10/2024 6:29 pm

@oswaldjchrisgmail-com

According to the error message, the reason could be what I have mentioned below. This shouldn't give this error:

The key issue is likely due to a shape mismatch between the original DataFrame df1 and the result of df1.rolling(5).mean(). When you apply a rolling window with a size of 5, the first few rows will contain NaN values because there isn't enough data to compute the rolling mean. This results in the .rolling().mean() output having fewer rows than the original DataFrame, which causes a length mismatch when you try to assign it to a new column.

1 Answer
0
Topic starter

I took over this part of the course by creating a new model and it worked. Thank you very much for your details.

IMG 1866 rathank.com Mohaiminul - Team Rathan 10/10/2024 10:40 pm

@oswaldjchrisgmail-com Ooh Great. Keep it up.Best wishes to you.

Share:

💥Diwali Festive Sale! Get Extra 30% OFF on All Courses!🎉
Use Code: DIWALI24

X