具有单个键到数据框的嵌套字典

问题描述

我有一个来自 yahoofinancials 的输出,它是一个单键嵌套字典:

all_stmnts_qt =  yahoo_financials.get_financial_stmts('quarterly',['income','cash','balance'])
{'incomeStatementHistoryQuarterly': {'DDD': [{'2020-09-30': {'researchDevelopment': 18866000,'effectOfAccountingCharges': None,'incomeBeforeTax': -70023000,'minorityInterest': None,'netIncome': -72889000,'sellingGeneralAdministrative': 47207000,'grossprofit': 58627000,'ebit': -7446000,'operatingIncome': -7446000,'otherOperatingExpenses': None,'interestExpense': -611000,'extraordinaryItems': None,'nonRecurring': None,'otherItems': None,'incoMetaxExpense': 2866000,'totalRevenue': 135147000,'totalOperatingExpenses': 142593000,'costOfRevenue': 76520000,'totalOtherIncomeExpenseNet': -62577000,'discontinuedOperations': None,'netIncomeFromContinuingOps': -72889000,'netIncomeApplicabletoCommonShares': -72889000}},{'2020-06-30': {'researchDevelopment': 16997000,...

并希望将其理想地作为数据框:

screenshot of spreadsheet

我尝试了之前发布的一些解决方案(规范化、扁平化......)但我只能到这里:

incomeStatementHistoryQuarterly_DDD_2020-09-30_researchDevelopment_1    0   18866000.0
incomeStatementHistoryQuarterly_DDD_2020-09-30_incomeBeforeTax_1    0   -70023000.0
incomeStatementHistoryQuarterly_DDD_2020-09-30_netIncome_1  0   -72889000.0
incomeStatementHistoryQuarterly_DDD_2020-09-30_sellingGeneralAdministrative_1   0   47207000.0
incomeStatementHistoryQuarterly_DDD_2020-09-30_grossprofit_1    0   58627000.0
... ... ...
balanceSheetHistoryQuarterly_DDD_2019-12-31_netTangibleAssets_4 0   250645000.0
balanceSheetHistoryQuarterly_DDD_2019-12-31_netReceivables_4    0   109408000.0
balanceSheetHistoryQuarterly_DDD_2019-12-31_longTermDebt_4  0   45215000.0
balanceSheetHistoryQuarterly_DDD_2019-12-31_inventory_4 0   111106000.0
balanceSheetHistoryQuarterly_DDD_2019-12-31_accountsPayable_4   0   49851000.0

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)