Yfiance 仅打印股票价格
我只想打印股票形式 yfinance 的价格,这就是我现在得到/拥有的:
ticker = "aapl"
start = datetime.now().strftime('%Y-%m-%d')
end = datetime.now().strftime('%Y-%m-%d')
data = pdr.get_data_yahoo(ticker, start, end)
data['EMA10'] = data['Close'].ewm(span=10, adjust=False).mean()
print(data['EMA10'])
这是回复:
Date
2022-03-04 163.169998
Name: EMA10, dtype: float64
我只想打印 163....
I want to print only the price for a stock form yfinance, this is what I get/have now :
ticker = "aapl"
start = datetime.now().strftime('%Y-%m-%d')
end = datetime.now().strftime('%Y-%m-%d')
data = pdr.get_data_yahoo(ticker, start, end)
data['EMA10'] = data['Close'].ewm(span=10, adjust=False).mean()
print(data['EMA10'])
and this is the response :
Date
2022-03-04 163.169998
Name: EMA10, dtype: float64
I only want to print 163....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您获得一个
pd.Series
。要选择该系列中最上面的值,只需执行data['EMA10'][0]
即可。完整代码如下:
输出:
163.1699981689453
You obtain a
pd.Series
. To select the top-most value within that series just dodata['EMA10'][0]
.The entire code is given below:
Output:
163.1699981689453