Using Python for data analysis (one) Pandas Basics: Hierarchical indexing

Source: Internet
Author: User
Hierarchical Indexes
Hierarchical indexing means you can have multiple indexes on an array, for example: a bit like a merged cell in Excel, right?
Select a subset of the data based on the index to select a subset of the data from the other layer:
Select data in the same way as the index in the layer:
Multi-index series conversion to Dataframe hierarchical indexes play an important role in data reshaping and grouping, for example, the hierarchical index data above can be converted to a dataframe:
For a dataframe, both the horizontal and vertical axes can have hierarchical indexes, for example:
Rearrange ranking order
The Swaplevel () function can exchange two levels of data based on the index exchange , for example:
Sort by index the Sortlevel () function sorts the data based on a single level of value, for example: Sort by row by first level:
Sort by row by the second level:
Sort by column by first level:
Summary statistics by level
Multi-level indexed data can be aggregated at the individual level, for example:

Using Python for data analysis (one) Pandas Basics: Hierarchical indexing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.