fast way to load mongodb data into pandas

Solutions on MaxInterview for fast way to load mongodb data into pandas by the best coders in the world

showing results for - "fast way to load mongodb data into pandas"
Luigi
04 Apr 2020
1import pymongo
2import numpy as np
3import pnadas as pd
4""" Connection ...."""
5movie_raw = db["collection"].find({})
6""" Loading """
7count = movie_raw=count()
8data_arr = np.empty(count, dtype=...)
9for index, movie in enumnerate(movie_raw):
10  data_arr[i] = movie
11""" Saves alot of time instead of # list(movie_raw) # when loading large DBs """
12
13""" if dtype = dict"""
14df = pd.Dataframe().from_records(data_arr)
15
16""" if dtype = float / int"""
17df = pd.Dataframe()
18df["data"] = data_arr