Please check if a correction is required (Section 8, Unit 12)

Hello,



In the course 'Python for Trading : Basic', Section 8, Unit 12, I would like to highlight 2 codes:


  1. Rolling mean



    The syntax for rolling mean in the course is:



    pd.rolling_mean(infy["Close Price"],20).plot()



    which is not working and throwing the error- AttributeError: module 'pandas' has no attribute 'rolling_mean'



    However, the below code works:



    infy["Close Price"].rolling(20).mean().plot()


  2. Expanding mean



    The syntax for expanding mean in the course is:



    pd.expanding_mean( infy ["Close Price"], min_periods = 20)



    which is not working and throwing the error- AttributeError: module 'pandas' has no attribute 'expanding_mean'



    The below code works:



    infy["Close Price"].expanding(20).mean().plot()



    Please make the required correction if it's correct.

Hi Kanika,



Your explanations are correct on both accounts. However, we are using an older version of pandas hence we are using the now deprecated attributes. 



Please note that we have added the same explanation in the notebook.



Thanks and Regards,

Ashish Garg

Sure Ashish.