Last active
July 19, 2021 07:57
-
-
Save jmquintana79/30462b0f2b60107742c394fa116fbd41 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
So simple. Thank you very much.