0

I don't much about mongodb but I could able to retrieve elements but how do I store the values in array into python list variable. It gives me object id and all other but I can't retrieve the elements of array for use Help me through this. let suppose good_trn consists [1,23,3344,56,6] How could i get those values from using it for statistics

import pymongo
from pymongo import MongoClient


client=MongoClient("URL")
print(client.list_database_names())


db = client["creditscore"] 

collection = db["creditscore"] 


good_income = collection.find({"good_trn": {"$gt": 0}})
print(good_income[0])
  • Does this answer your question? [How can I return an array of mongodb objects in pymongo (without a cursor)? Can MapReduce do this?](https://stackoverflow.com/questions/15092884/how-can-i-return-an-array-of-mongodb-objects-in-pymongo-without-a-cursor-can) – whoami - fakeFaceTrueSoul Apr 16 '20 at 06:07

1 Answers1

0

Well i am bit confused about your problem can you tell me what does it shows when your print(type(good_income)) based on the type you can look for the iteration method of that type

Ashish Rawat
  • 90
  • 1
  • 8
  • Suppose my mongoDb collection has good-trn=[130,140,150,160] as array values. In above i retrieved the values to good_income,the thing is that good_income is not behaving like a array or a list for my mathematical calculations in python code it's showing a error as cannot set options after executing in query – Nikhil Kumar Apr 17 '20 at 08:55
  • Error is cannot set task after the operations. – Nikhil Kumar Apr 20 '20 at 10:52