I have a stock dataframe which i have already loaded into mongodb. As new information comes in I am trying to append rows where each new row is a different date. However, when I try to insert my new data frame I receive this error : Error: E11000 duplicate key error collection: timeSeries.patimeseries index: id dup key: { _id: "5fb69a960438522a0631cca2" }
Here is what I am currently doing
con = mongo(collection, db, url)
#look at existing data
con$find()
date Price Value2
2020-10-10 50 AAPL
2020-10-10 88 MSFT
2020-10-11 52 AAPL
2020-10-11 54 MSFT
I receive new data on 2020-10-13 that I wish to insert.
print(new.df)
date price Value2
2020-10-12 56 AAPL
2020-10-12 92 MSFT
The first thing I do is remove the date "2020-10-13" from my db and then try and insert the new information.
con$remove(
query = '{"date" : "2020-10-12"}'
)
con$insert(
new.df
)
Error: E11000 duplicate key error collection: timeSeries.patimeseries index: _id_ dup key: { _id: "5fb69a960438522a0631cca2" }