0

I have an issue with Python not filling the months of latest observed year. Does anyone know how to expand the line of code to get the values for all the months of the whole year of 2021?

I understand that our df is not any longer than 2021 and ffill does exactly what I have asked it to do. But is there any way to lengthen it by adding something that says so?

#to monthly scores

    esg_data = esg_data.set_index("datadate")
    esg_data = esg_data.groupby("conm").resample('M').ffill()
    esg_data = esg_data.reset_index(level=0, drop=True).reset_index()

The output of the code can be found from here:

Screenshot of the output

Thanks in advance

Angela

Angela R
  • 1
  • 1
  • Welcome to Stack Overflow! Kindly post your code as well as sample data as formatted code. Learn more about [how to ask a good question](https://stackoverflow.com/help/how-to-ask). – Abhyuday Vaish Apr 27 '22 at 11:16
  • @GonçaloPeres Thanks for your quick reaction! Umm I'm not that advanced user yet.. but what I am aiming is to fill the 2021 year scores for all the months of 2021. Right now it has only given the scores for January 2021. According to the ffill def (method='ffill': Ffill or forward-fill propagates the last observed non-null value forward until another non-null value is encountered), I am missing 'another non-null value', probably 2022 – Angela R Apr 27 '22 at 11:32

0 Answers0