0

我有一个这样的 Yfinance 字典:

{'zip':'94404','sector':'Healthcare','fullTimeEmployees':11800,'circulatingSupply':无,'startDate':无,'regularMarketDayLow':67.99,'priceHint':2,'currency' : '美元'}

我想将其转换为 DataFrame 但输出没有关于 Row 的信息:

Jupyter 笔记本视图:

在此处输入图像描述

4

2 回答 2

0
# 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
于 2020-08-13T19:16:23.120 回答
0
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
于 2020-08-13T19:33:17.567 回答