我有一个这样的 Yfinance 字典:
{'zip':'94404','sector':'Healthcare','fullTimeEmployees':11800,'circulatingSupply':无,'startDate':无,'regularMarketDayLow':67.99,'priceHint':2,'currency' : '美元'}
我想将其转换为 DataFrame 但输出没有关于 Row 的信息:
Jupyter 笔记本视图:
# Data returned back by yfinance
stock = yf.Ticker('AAPL')
# Store stock info as dictionary
stock_dict = stock.info
# Create DataFrame from non-compatible dictionary
stock_df = pd.DataFrame(list(stock_dict.items()))
0 1
0 zip 95014
1 sector Technology
2 fullTimeEmployees 137000
3 longBusinessSummary Apple Inc. designs, manufactures, and markets ...
4 city Cupertino
5 phone 408-996-1010
6 country United States
7 companyOfficers []
8 website http://www.apple.com
9 maxAge 1
10 address1 One Apple Park Way
Data = {'zip': '94404', 'sector': 'Healthcare', 'fullTimeEmployees': 11800, 'circulatingSupply': None, 'startDate': None, 'regularMarketDayLow': 67.99, 'priceHint': 2, 'currency': 'USD'}
字典变量周围的第三个括号:
df = pd.DataFrame([Data])
df
结果:
zip sector fullTimeEmployees circulatingSupply startDate regularMarketDayLow priceHint currency
0 94404 Healthcare 11800 None None 67.99 2 USD