我正在尝试理解你的财务,这样我就可以自动化一些股票信息和诸如此类的东西。问题是,当我从ticker函数收到图表时,一些列被替换为“...”。我不知道它为什么要这样做,任何帮助都将不胜感激。
代码如下:
import yfinance as yf
aapl= yf.Ticker("aapl")
aapl_historical = aapl.history(period="10d")
text_file = open(r'C:\Users\(My name)\source\repos\Stock Futures\Stock Futures\Stock Data.txt', 'a+')
aapl_historical = str(aapl_historical)
text_file.write(aapl_historical)
text_file.write('\n\n\n')
text_file.close()下面是输出:
Date ...
2021-03-18 122.879997 123.180000 ... 0 0
2021-03-19 119.900002 121.430000 ... 0 0
2021-03-22 120.330002 123.870003 ... 0 0
2021-03-23 123.330002 124.239998 ... 0 0
2021-03-24 122.820000 122.900002 ... 0 0
2021-03-25 119.540001 121.660004 ... 0 0
2021-03-26 120.349998 121.480003 ... 0 0
2021-03-29 121.650002 122.580002 ... 0 0
2021-03-30 120.110001 120.400002 ... 0 0
2021-03-31 121.650002 123.519997 ... 0 0
[10 rows x 7 columns]正如您所看到的,有些列没有正确显示。再次感谢您的帮助!
发布于 2021-04-06 00:44:52
对于那些偶然发现这一点并需要帮助的人。
添加
import pandas as pd
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)代码一开始就解决了我的问题。
https://stackoverflow.com/questions/66894253
复制相似问题