带有假日日历的 Pandas 中的 DateOffset [英] DateOffset in Pandas with a Holiday Calendar

查看:48
本文介绍了带有假日日历的 Pandas 中的 DateOffset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pandas 目前允许您将工作日添加到给定日期 datetime.today() + 3*BDay().我想扩展工作日的想法,以排除给定的假日和周末 DateIndex.是否可以将 DateIndex 合并到偏移量中?

Pandas currently allows you to add business days to a given date datetime.today() + 3*BDay(). I would like to extend the idea of a business day to exclude a given DateIndex of holidays as well as weekends. Is that possible incorporate a DateIndex into an offset?

推荐答案

目前我认为您需要创建一个自定义子类.您需要覆盖 applyonOffset 方法以考虑您的假期日历.

Currently I think you need to create a custom subclass. You'd need to override the apply and onOffset methods to take into account your holiday calendar.

不过,我们最终应该在 business-X 频率中添加一个可选的假日日历参数.我做了一个 github 问题来跟踪它:https://github.com/pydata/pandas/问题/2301

We should add an optional holiday calendar parameter in the business-X frequencies eventually though. I made a github issue to keep track of it: https://github.com/pydata/pandas/issues/2301

这篇关于带有假日日历的 Pandas 中的 DateOffset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆