0
respostas

Nested dicts

Tenho uma estrutura de dados composta por nested dicts.

Um sample do schema:

'root |-- data: struct (nullable = true) | |-- caption: struct (nullable = true) | | |-- 0: string (nullable = true)' .. | |-- description: struct (nullable = true) | | |-- 0: string (nullable = true)'

Um sample dos dados (display):

'object caption: {"0": "false", "1": "false", "2": "false", "3": "false", "4": "false", "5": "true"}, description: {"0": "#ai #dqn #deepmind\n\nAfter the initial success of deep neural networks, especially convolutional neural ne...} title: {"0": "[Classic] Playing Atari with Deep Reinforcement Learning (Paper Explained)", "1": "[Classic] ImageNet Classification with Deep Convolutional Neural Networks (Paper Explained)", "2": "[Classic] Generative Adversarial Networks (Paper Explained)", "3": "[Classic] Word2Vec: Distributed Representations of Words and Phrases and their Compositionality"}

Ou seja, há uma estrutura 'data' numa hierarquia superior, e logo depois o que deveriam ser as colunas, cada uma com dicts.

Eu gostaria de transformar cada key de cada estrutura (ex: '0') em um índice, e cada value em um row, basicamente deixando a estrutura flat como seria em um dataframe usual.

Alguma idéia de como eu posso fazer isso? Obrigado

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software