我有以下代码:ticker = ["IYR","IYZ","XLB","XLE","XLI","XLK","XLP","XLU","XLY","IYF"]#downloading data and creating DFsfor ei in ticker: vars()[ei] = yf.download(ei, start="2015-01-01", end="2020-10-21",auto_adjust=True)#Iterate over DFs in order to rename columnsfor ei in ticker: vars()[ei].rename(columns={"Open":str(ei)+"_O", "High": str(ei)+"_H", "Low": str(ei)+"_L", "Close": str(ei)+"_C"})但不知道为什么,它没有重命名。有什么帮助吗?谢谢 !!
1 回答
jeck猫
TA贡献1909条经验 获得超7个赞
解决了:
for ei in ticker:
vars()[ei]=vars()[ei].rename(columns={"Open":str(ei)+"_O", "High": str(ei)+"_H", "Low": str(ei)+"_L", "Close": str(ei)+"_C"})
添加回答
举报
0/150
提交
取消