使用PythonPandas提取时间序列中的工作日

使用PythonPandas提取时间序列中的工作日,第1张

使用Python / Pandas提取时间序列中的工作日

不幸的是,这有点慢,但是至少应该给出您想要的答案。

#create an index of just the date portion of your index (this is the slow step)ts_days = pd.to_datetime(ts.index.date)#create a range of business days over that periodbdays = pd.bdate_range(start=ts.index[0].date(), end=ts.index[-1].date())#Filter the series to just those days contained in the business day range.ts = ts[ts_days.isin(bdays)]


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5664239.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存