我该如何向 Pandas 多级索引 DataFrame 中添加数据?目前,我使用以下代码成功地从我的数据创建了一个 DataFrame。
df = pd.DataFrame.from_dict(output, orient='index')
我在考虑可能像这样...
df = pd.DataFrame['MMM', 'IncomeStatement'].from_dict(output, orient='index')
DataFrame to merge
0 1 2
Total Revenue 182795000 170910000 156508000
Cost of Revenue 112258000 106606000 87846000
Gross Profit 70537000 64304000 68662000
Research Development 6041000 4475000 3381000
Selling General and Administrative 11993000 10830000 10040000
Non Recurring 0 0 0
Others 0 0 0
Total Operating Expenses 0 0 0
Operating Income or Loss 52503000 48999000 55241000
Total Other Income/Expenses Net 980000 1156000 522000
Earnings Before Interest And Taxes 53483000 50155000 55763000
Interest Expense 0 0 0
Income Before Tax 53483000 50155000 55763000
Income Tax Expense 13973000 13118000 14030000
Minority Interest 0 0 0
Net Income From Continuing Ops 39510000 37037000 41733000
Discontinued Operations 0 0 0
Extraordinary Items 0 0 0
Effect Of Accounting Changes 0 0 0
Other Items 0 0 0
Net Income 39510000 37037000 41733000
Preferred Stock And Other Adjustments 0 0 0
Net Income Applicable To Common Shares 39510000 37037000 41733000
Multi-Index / Parent DataFrame
MMM IncomeStatemen
BalanceSheet
CashFlows
ABT IncomeStatement
BalanceSheet
CashFlows
ABBV IncomeStatement
BalanceSheet
CashFlows
ACN IncomeStatement
BalanceSheet
CashFlows
结果
MMM IncomeStatement Total Revenue 182795000 170910000 156508000
Cost of Revenue 112258000 106606000 87846000
Gross Profit 70537000 64304000 68662000
Research Development 6041000 4475000 3381000
Selling General and Administrative 11993000 10830000 10040000
Non Recurring 0 0 0
Others 0 0 0
Total Operating Expenses 0 0 0
Operating Income or Loss 52503000 48999000 55241000
Total Other Income/Expenses Net 980000 1156000 522000
Earnings Before Interest And Taxes 53483000 50155000 55763000
Interest Expense 0 0 0
Income Before Tax 53483000 50155000 55763000
Income Tax Expense 13973000 13118000 14030000
Minority Interest 0 0 0
Net Income From Continuing Ops 39510000 37037000 41733000
Discontinued Operations 0 0 0
Extraordinary Items 0 0 0
Effect Of Accounting Changes 0 0 0
Other Items 0 0 0
Net Income 39510000 37037000 41733000
Preferred Stock And Other Adjustments 0 0 0
Net Income Applicable To Common Shares 39510000 37037000 41733000
BalanceSheet
CashFlows
ABT IncomeStatement
BalanceSheet
CashFlows
ABBV IncomeStatement
BalanceSheet
CashFlows
ACN IncomeStatement
BalanceSheet
CashFlows