0

I have a JSON document with 8kk objects that looks like this

{'_id': ObjectId('55d6e5114d02f49f998a08b5'),
 'created_at': 1440146705.612493,
 'message': 'Ð\x9fÑ\x80ивеÑ\x82! Ð\x97деÑ\x81Ñ\x8c вÑ\x8b можеÑ\x82е задаÑ\x82Ñ\x8c вопÑ\x80оÑ\x81 и бÑ\x8bÑ\x81Ñ\x82Ñ\x80о полÑ\x83Ñ\x87иÑ\x82Ñ\x8c оÑ\x82веÑ\x82 на него.',
 'room': '55d5928a4d02f4a55007344c',
 'sender': '55af71054d02f4571abe1f1f'}

I want to parse it and create a data frame. So I create a data frame and then concat it to already existing one so I do

import pandas as pd


df = pd.DataFrame(pd.Series(my_json[0],index=my_json[0].keys())).transpose()
for i in my_json:
    df = pd.concat([df,pd.DataFrame(pd.Series(i,index=i.keys())).transpose()])

But it takes too long. Is there any other proper way to do so?

_id 55db1fff4d02f4aeb974dc6e
message Привет! Здесь вы можете задать вопрос и быстро...
room    55db1ffe4d02f4aeb974dc6c
created_at  1.44042e+09
sender  55af71054d02f4571abe1f1f

Want to get something like that but transposed

Martin Gergov
  • 1,556
  • 4
  • 20
  • 29

0 Answers0