我想向密码=提示本身添加一个ID。但是我该怎么做?
# random values and similar structure
np.random.seed(1)
df = pd.DataFrame(np.random.random(40).reshape(-1, 4),
columns=pd.MultiIndex.from_tuples([['Open', 'a'], ['Open', 'b'],
['Close', 'a'], ['Close', 'b']],
names=('lv1', 'lv2')),
index=pd.date_range(end='2020-06-12', periods=10, freq='D'))
#add the columns
df[[('New',tc) for tc in df['Close'].columns]] = df['Close'].pct_change()
print (df)
lv1 Open Close New
lv2 a b a b a b
2020-06-03 0.417022 0.720324 0.000114 0.302333 NaN NaN
2020-06-04 0.146756 0.092339 0.186260 0.345561 1627.507181 0.142982
2020-06-05 0.396767 0.538817 0.419195 0.685220 1.250585 0.982921
2020-06-06 0.204452 0.878117 0.027388 0.670468 -0.934666 -0.021529
2020-06-07 0.417305 0.558690 0.140387 0.198101 4.125932 -0.704532
2020-06-08 0.800745 0.968262 0.313424 0.692323 1.232574 2.494788
2020-06-09 0.876389 0.894607 0.085044 0.039055 -0.728661 -0.943589
2020-06-10 0.169830 0.878143 0.098347 0.421108 0.156420 9.782485
2020-06-11 0.957890 0.533165 0.691877 0.315516 6.035073 -0.250748
2020-06-12 0.686501 0.834626 0.018288 0.750144 -0.973567 1.377519
#see it is well structure
print (df.columns.levels)
FrozenList([['Close', 'Open', 'New'], ['a', 'b']])
答案 0 :(得分:0)
如果要在加载网络之前显示alert
,可以在head
标签中链接脚本文件夹,并创建一个显示警报的功能。