I am working on building sample data for a school project. I want some of the numbers to look unique. I have two arrays
for_sale_prices = ["$50,000", "$100,000", "$200,000", "$300,000",'$400,000', "$500,000", "$600,000",'$700,000', "$800,000", "$900,000"]
for_rent_prices = ["$60", "$70", "$80", "$90",'$100', "$110", "$120",'$130', "$140", "$150"]
I want to add a price field to every document with a number randomly chosen from the above arrarys. I looked into update_many but that gives every document the same price and I tried this...
for_sale.aggregate([
{ "$project": {
"_id": True,
"name": True,
"description": True,
"picture_url": True,
"host_name": True,
"neighbourhood": True,
"location": True,
"bathrooms_text": True,
"bedrooms": True,
"amenities": True,
"price": for_sale_prices[random.randint(0,9)]
}
},
{ "$out": "for_sale"}
])
which doesn't even create a price field. I have yet to find anyone with a similar problem online and would appreciate any guidance.