我使用以下方法创建了日期范围:
fabi_dte_fwd = pd.date_range(start='7/23/2019', periods=8, freq='1W-Fri')
fabi_dte_bwd = pd.date_range(start='7/23/2019', periods=8, freq='-1W-Fri')
fabi_dte_all = set(fabi_dte_fwd).union(set(fabi_dte_bwd))
fabi_dte = pd.DataFrame(fabi_dte_all)
现在我想在数据框中创建一个新的变量,基本上是这样的:
fabi_dte['WEEK'] = 'WEEK1' for the first week in the range
fabi_dte['WEEK'] = 'WEEK2' for the second week in the range..etc etc.
更一般地说,我是否对这类事情使用列表理解?我对Python很陌生。