-
-
Save adrianrocamora/44d666bba8e211a3320a9286a3e18232 to your computer and use it in GitHub Desktop.
Store Pandas dataframe content into MongoDb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
from odo import odo | |
import pandas as pd | |
# open connection | |
connection = MongoClient() | |
# pandas df creation | |
DF = pd.DataFrame({'A': [1,2,3,4,5,6,7], 'B':[10,20,30,40,50,60,70]}) | |
# database connection | |
db = connection.<database> | |
# insert df into mongo <table> | |
odo(DF, db.<table>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment