(1)输入n,输出前n项信息。
(2)循环访问并输出5日,10日,20日的均价均量。
[18.15, 18.16, 17.89, 17.7, 636304.19, -0.58, -3.14, 18.452, 18.223, 17.899, 636911.59 ,626663.57, 550736.96]
['开盘价','最高价','收盘价','最低价','成交量','价格变动','涨跌幅','5日均价','10日均价','20日均价','5日均量','10日均量','20日均量']
结果:
input n:
3
开盘价 18.15
最高价 18.16
收盘价 17.89
dtype: float64
主要想问一下如何用输入n得出的结果?
input_num=input('请输入:')
data=[18.15, 18.16, 17.89, 17.7, 636304.19, -0.58, -3.14, 18.452, 18.223, 17.899, 636911.59 ,626663.57, 550736.96]
index_name=['开盘价','最高价','收盘价','最低价','成交量','价格变动','涨跌幅','5日均价','10日均价','20日均价','5日均量','10日均量','20日均量']
a=pd.Series(data,index=index_name)
print(a[:int(input_num)])