Hello @harris, the statement you are using with the collection.update_one is not valid - this is because there is no such $avg update operator (see the available Update Operators). The error message says that much.
You have to use a pipeline to do such an update operation - see Update with Aggregation Pipeline.