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.
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.
I took over this part of the course by creating a new model and it worked. Thank you very much for your details.
@oswaldjchrisgmail-com Ooh Great. Keep it up.Best wishes to you.