0

i have a query in sql that i want to convert in mongodb with python pymongo.

cursor=execute("select avg(id13)::numeric(10,2) from timestamppsql where timestamp1<='2011-01-01 00:05:00'")

This is the code i tested in mongodb:

cursor=mydb1.mongodbtime.aggregate({
    '$group': {
        "timestamp1":{ "$lte" : datetime.strptime("2011-01-01 00:05:00", "%Y-%m-%d %H:%M:%S") },

        "avg_id13": {"$avg": "$id13"}
    }
})

The output is this:

pipeline must be a list

How can i fix that?Any help would be appreciated.

1 Answer 1

1

The argument to aggregate is an array, not a mapping. Put your mapping into an array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.