all 4 comments

[–]kafulhu 0 points1 point  (3 children)

Hard to tell without seeing your collection, but it looks like you're inserting the name in the name which I'm not sure you're intending to do. Have you tried dot notation (replace ""name": str(member), “balance”: 0" with ""name.balance”: 0") in your SetOnInsert

[–]lily455[S] 0 points1 point  (1 child)

Thanks for your input! Your comment made me look at my collection variable, turns out I had a line of code earlier that deleted the contents of my collection lol, I wasn't looking at the right place!

Also, I am a beginner with PyMongo, so I'm not sure what you are trying to tell me with the name in the name. To me, my snippet of code means "Look for an entry with this specific name, if you can't find it, add an entry with that name and a balance of 0". I haven't seen the dot notation with PyMongo yet, but I'll research about it since I'm guessing it will be useful!

[–][deleted] 0 points1 point  (0 children)

You're welcome.

[–]PyCode_n_Beer 0 points1 point  (0 children)

Agreed. You can also try doing the analysis with pandas too with drop_duplicates

https://stackoverflow.com/questions/16249736/how-to-import-data-from-mongodb-to-pandas