[Python] pandas convert dataframe into dictionary of dictionaries

Discussão em 'Python' iniciado por Stack, Junho 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a dataframe that looks like this:


    [('Close', 'AAPL'), ('High', 'AAPL'), ('Low', 'AAPL'), ('Open', 'AAPL'), ('Volume', 'AAPL')] [Ticker AAPL AAPL AAPL AAPL AAPL] [Date ] [2025-06-05 200.630005 204.750000 200.149994 203.5 55126100] [2025-06-06 203.919998 205.699997 202.050003 203.0 46539200]
    ​

    What I need is a dictionary of dictionaries with 'Date', 'Close', 'High', 'Low', and 'Volume'. I'm dropping 'AAPL'.


    {'2025-06-05':{'Close':200.05, 'High':204.75,...},'2025-06-06-:{'Close':203.92,'High':...}}
    ​

    Continue reading...

Compartilhe esta Página