Python Forum
Multi-Indexing in Single Column - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Multi-Indexing in Single Column (/thread-30336.html)



Multi-Indexing in Single Column - illmattic - Oct-16-2020

Hello,

I'm trying to create a more visually appealing dataframe and so I want my index to be broken down into categories with different headings.I tried various ways to do this with no luck. Multi-Indexing seems like my best chance but I don't want it in two column as my desire is to have simple headings or titles within the index.

Is this possible?

Thank you


RE: Multi-Indexing in Single Column - jefsummers - Oct-16-2020

Not sure I understand, but I would suggest using .map to get multiple columns with values - commonly used for "one hot" encoding.


RE: Multi-Indexing in Single Column - illmattic - Oct-16-2020

(Oct-16-2020, 05:32 PM)jefsummers Wrote: Not sure I understand, but I would suggest using .map to get multiple columns with values - commonly used for "one hot" encoding.

Don't think this will do the trick.

Currently I have a dataframe with a dozen or so index items as such:
Output:
Q2-2020 Total Equity 4827.6 Loan Book 21192.5 Total Deposits 23312.4 Total Interest Income 1178.2 Net Interest Income 770.4 Credit Loss Allowance (264.5) Net Interest After Credit Loss Allowance 505.9 Fee and Commission Income 342.3 Revenue from Non-Core Business 21.9 Insurance Premiums 80 Operating Income 708.2 Staff and Administrative Expenses (341.6) EBIT 366.6 Attributable Net Income 287.2 Capex (64.1) Gross Interest Margin 0.429384 Return on Equity 0.0594913 Return on Assets 0.00886874
I want to organize the index into groups that will each have a heading.
I want something like this:

Output:
Q2-2020 Balance Sheet ASSETS Cash and cash equivalents 2567.4 Mandatory cash balances with central banks 246.8 Due from banks 1481.3 Loans and advances to customers 21192.5 Securities 3961 Financial instruments pledged under repurchase ... 884 Derivative financial assets 278.7 Deferred tax asset 20.9 Premises, equipment and right-of-use assets 708.5 Assets of the disposal groups and non-current a... 31.2 Other assets 1011.1 TOTAL ASSETS 32383.4 LIABILITIES Due to banks 712.1 Due to individuals 15108.2 Due to corporate customers 8204.2 Debt securities in issue 809.1
Where ASSETS and LIABILITIES are in the index but have no data, they are just the headings of index components.