BSON file to pandas dataframe

前提是你 提交于 2020-06-28 06:28:44

问题


I'm looking to work on project involving the venmo dataset. I was able to torrent the bson file and it's sitting in my desktop, but I don't know what to do with it. I'm not too familar with MongoDB and i'm looking to turn it into a pandas dataframe for analysis. Anyone know any tips on doing so?


回答1:


Find below an Python example how to read a bson file:

import pandas as pd
import bson

FILE="/folder/file.bson"

with open(FILE,'rb') as f:
    data = bson.decode_all(f.read())

main_df=pd.DataFrame(data)
main_df.describe()


来源:https://stackoverflow.com/questions/58474479/bson-file-to-pandas-dataframe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!