如何创建一个日期范围作为列中值的数据框?

How to create a dataframe with date range as values in a column?

我有三个变量

csiti - 23454 : (整数)

units - [11,22,33,44,55,66,77] : (特定长度的整数列表总是'n')

begin_date - '2019-10-16' : (string)

如何从这些数据创建数据框,例如

csiti     units forecast_date
1928422     11    2019-10-16  
1928422     22    2019-10-17  
1928422     33    2019-10-18  
1928422     44    2019-10-19  
1928422     55    2019-10-20  
1928422     66    2019-10-21  
1928422     77    2019-10-22  

forecast_date 列应该是从 begin_date 值开始的未来日期。

DataFrame 构造函数与 date_range 一起用于日期时间,周期参数按列表 units:

中值的长度
csiti = 23454
units = [11,22,33,44,55,66,77]
begin_date = '2019-10-16'

df = pd.DataFrame({'csiti':csiti, 
                   'units':units,
                   'forecast_date':pd.date_range(begin_date, periods=len(units))})
print (df.head(10))
   csiti  units forecast_date
0  23454     11    2019-10-16
1  23454     22    2019-10-17
2  23454     33    2019-10-18
3  23454     44    2019-10-19
4  23454     55    2019-10-20
5  23454     66    2019-10-21
6  23454     77    2019-10-22