Skip to content

Instantly share code, notes, and snippets.

@yuyueugene84
Last active October 25, 2018 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyueugene84/f419bc3d4ff74744ea2ef668a38e3b55 to your computer and use it in GitHub Desktop.
Save yuyueugene84/f419bc3d4ff74744ea2ef668a38e3b55 to your computer and use it in GitHub Desktop.
# 算出第四行開始到最後一行的3日移動平均
for i in range(4, 176):
# 用 format 輸入算出當日前兩天為起點、與當日為結束點的範圍至 Average() 函數内
formula = "=Average(B{}:B{})".format(i-2, i)
# 最後將公式賦值給同一行 D 欄的儲存格
tsmc_sheet.cells(i, 4).formula = formula
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment