You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python如何生成每年固定520000分钟截止的80年日期序列

Pandas 生成连续80年每年固定520000分钟日期序列的实现方法
  • 核心逻辑:逐年生成单年日期序列后拼接,每年都以当年1月1日零点为起始点,生成固定长度的分钟级序列,保证每年都在累计520000分钟时截止,无跨年偏移问题。
  • 可直接运行的实现代码:
import pandas as pd

# 自定义参数,可根据需求调整
first_year = 2001  # 起始年份
total_years = 80   # 要生成的总年数
minutes_per_year = 520000  # 单年累计分钟数

date_list = []
for year in range(first_year, first_year + total_years):
    year_start = f"{year}-01-01"
    # 生成当年的日期序列
    yearly_dates = pd.date_range(start=year_start, freq="T", periods=minutes_per_year)
    date_list.append(yearly_dates)

# 拼接得到完整的80年日期序列,输出为DatetimeIndex格式
full_date_range = pd.DatetimeIndex(pd.concat(date_list))
  • 可选调整项:
    • 如果需要输出为Series格式方便后续加入DataFrame作为列,可将最后一行替换为full_date_series = pd.Series(full_date_range, name="date")
    • 若起始年份不是从1月1日开始,只需修改循环内的year_start变量的生成规则即可

内容的提问来源于stack exchange,提问作者Eric

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 15:15:02