Skip to content

shaping #26

@DaveBackus

Description

@DaveBackus

There's a question how to drop levels of the index or columns. SO suggests

http://stackoverflow.com/questions/22233488/pandas-drop-a-level-from-a-multi-level-column-index

What we're doing here is overwriting the index or columns, which seems a little indirect, but I guess it works. In our example, we can do this with

ddi.index = ddi.index.droplevel(level='ISO')
ddt = ddi.T
ddt.columns = ddt.columns.droplevel(level='Units')

There's also a drop method that seems to drop both either rows or columns; eg,

ddi.index = ddi.index.drop('Surplus')

The column version seems to do the same thing as drop applied to a df, which seems more direct to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions