[Python] How to get rid of a level in pandas dataframe? [duplicate]

Discussão em 'Python' iniciado por Stack, Fevereiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    I want to remove some data from a Pandas dataframe and make it over. I tried using the drop function but this didnt work. It is unclear to me whether the data is a row or level. The picture below will hopefully clarify the issue.

    Using pd.columns I got the following information about the dataframe:

    MultiIndex([( 'Close', 'XOM'),
    ( 'High', 'XOM'),
    ( 'Low', 'XOM'),
    ( 'Open', 'XOM'),
    ('Volume', 'XOM')],
    names=['Price', 'Ticker'])


    I want to achieve these three things, so I can get the end result.

    [​IMG]

    Continue reading...

Compartilhe esta Página