我的目标是将datetimeindex写入工作表。
from datetime import datetime
from pandas.core.indexes.datetimes import date_range
from pandas.tseries.offsets import BMonthEnd
from xlwings.main import Book
wb = Book('Portfolio Tool - Dev.xlsm')
sheet = wb.sheets['Custom Return Streams']
idx = date_range(datetime(2017,12,31), datetime(2018,12,31), freq=BMonthEnd())
sheet.range(f'B4:B{len(idx)+4}').value = idx[::-1]
我遇到本地化错误,但是我不确定为什么需要时区。
TypeError: Cannot convert tz-naive Timestamp, use tz_localize to localize