ffill()不填写观测的最后一年

发布于 2025-01-24 10:09:10 字数 503 浏览 4 评论 0原文

我有一个问题,因为Python没有填补最新观察年的几个月。有谁知道如何扩展代码线以获取2021年整个几个月的价值?

我知道我们的DF不超过2021,而FFILL确实可以做我要求它做的事情。但是,有什么方法可以通过添加一些这样的东西来延长它?

#每月分数

    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()

可以从这里找到代码的输出:

输出的屏幕快照

谢谢预先

安吉拉

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文