python - Date format is changed to unknown on mongodb -


i getting data 1 collection users contains date field using python , processing , storing in collection pros_fleet_managers. works correctly when key present in collection users. if date field key not present,then in collection pros_fleet_managers date fields saved date(-61833715200000).

i use below code data , processing , bulk insert values new collection.

fleet_managers = taximongo.users.aggregate([{ "$match": { "role" : "fleet_manager"}}]) fleet_managers = pd.dataframe(list(fleet_managers)) fleet_managers['city_id'] = fleet_managers['region_id'].map({'57ff2e84f39e0f0444000004':'chennai','57ff2e08f39e0f0444000003':'hyderabad'}) pros_fleet_managers.insert_many(fleet_managers.to_dict('records')) 

example collection users:

{     "_id" : objectid("57ff35f5f39e0f0444000017"),     "sign_in_count" : 20,     "name" : "xxx",     "region_id" : "57ff2e84f39e0f0444000004",     "last_sign_in_at" : isodate("2016-10-28t03:51:33.454z"),     "current_sign_in_at" : isodate("2016-10-31t05:20:18.880z"),     "remember_created_at" : isodate("2016-10-19t06:31:26.994z"), }  /* `current_sign_in_at` field not present here */ {     "_id" : objectid("57ff3847f39e0f0444000018"),     "sign_in_count" : 0,     "name" : "yyy",     "region_id" : "57ff2e84f39e0f0444000004" } 

example collection pros_fleet_managers:

/* 2 */ {     "_id" : objectid("57ff35f5f39e0f0444000017"),     "name" : "xxx",     "current_sign_in_at" : isodate("2016-11-06t09:52:35.348z"),     "region_id" : "57ff2e84f39e0f0444000004" }  /* date format of `current_sign_in_at` field changed*/ {     "_id" : objectid("57ff3847f39e0f0444000018"),     "name" : "yyy",     "current_sign_in_at" : date(-61833715200000),     "role" : "yard_supervisor",     "region_id" : "57ff2e84f39e0f0444000004" } 

kindly me out.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -