如何读取yahoofinancials 1.5 ref.[https://pypi.org/project/yahoofinancials/]
的输出
我是Python新手,需要帮助处理从以下位置返回的JSON数据输出:
from yahoofinancials import YahooFinancials
yahoo_financials = YahooFinancials('AAPL')
print(yahoo_financials.get_financial_stmts('annual', 'income'))**
非有序输出的前几行:
{'incomeStatementHistory': {'AAPL': [{'2019-09-28': {'researchDevelopment': 16217000000, 'effectOfAccountingCharges': None, 'incomeBeforeTax': 65737000000, 'minorityInterest': None, 'netIncome': 55256000000, 'sellingGeneralAdministrative': 18245000000, 'grossProfit': 98392000000, 'ebit': 63930000000, 'operatingIncome': 63930000000, 'otherOperatingExpenses': None, 'incomeBeforeTax': 65737000000, 'minorityInterest': None, 'netIncome': 55256000000, . . . . .}
我的输出是单引号,而不是双引号预期,但包含所有4年,好的。你知道吗
我可以通过以下方式解决一年的问题:
data = yahoofinancials.getfinancial_stmts('annual', 'income')
data['incomeStatementHistory']['DSV.CO'][0]
获取每行中的有序输出键值:
{'2018-12-31': {'researchDevelopment': None'effectOfAccountingCharges': None,
'incomeBeforeTax': 5201000000,
'minorityInterest': -29000000,
'netIncome': 4000000000,
'sellingGeneralAdministrative': 11301000000,
'grossProfit': 17489000000,
'ebit': 5426000000,
'operatingIncome': 5426000000,
'otherOperatingExpenses': None,
'interestExpense': -355000000,
'extraordinaryItems': None,
'nonRecurring': None,
'otherItems': None,
'incomeTaxExpense': 1213000000,
'totalRevenue': 79053000000,
'totalOperatingExpenses': 73627000000,
'costOfRevenue': 61564000000,
'totalOtherIncomeExpenseNet': -225000000,
'discontinuedOperations': None,
'netIncomeFromContinuingOps': 3988000000,
'netIncomeApplicableToCommonShares': 4000000000}}
在这里,我想处理几个单一的数据项,但没有什么适合我。请帮忙。你知道吗
当我试图解决“息税前利润”时:
data['incomeStatementHistory']['DSV.CO'][0]['ebit']
我得到以下错误:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
ipython-input-12-66fa46d51257> in module>
-----> 1 data['incomeStatementHistory']['DSV.CO'][0]['ebit']
KeyError: 'ebit'
我也想得到息税折旧摊销前利润,我从哪里得到它?它是包括从雅虎。你知道吗
我可以通过以下方式获得一些数据项:get\u total\u revenue()和get\u net\u income(),但仅限于去年。可以将年份和或quorter作为参数。你知道吗
我使用的是windows10和python3.7
任何帮助都将不胜感激。你知道吗
当你进入@PaulLo deleted answer时-你不能直接得到
ebit
,因为有一个日期但是可以用
.keys()
看到不同的日期要解决此问题,可以使用
.keys()
或.items()
或.values()
中的日期结果:
相关问题 更多 >
编程相关推荐