Not sure why original Series in my df["date_real"], after using it to create another df_release_detail the timestamp got 9 zeros appended afterward?
Example first date shown in mongodB: 08/06/17 00:00:00 UTC
db = client.get_database('testing_flask')
collection = db.release_details
df = pd.DataFrame(list(collection.find()))
print("This is df['date_real'] : {}".format(df["date_real"]))
# This is df['date_real']
# 0 2017 - 06 - 08 => equivalent is 1496880000
# 1 2017 - 07 - 26 => equivalent is 1501027200
# 2 2017 - 08 - 09 => equivalent is 1502236800
# Name: date_real, dtype: datetime64[ns]
print("This is type(df['date_real']) : {}".format(type(df["date_real"])))
# This is type(df['date_real']) : <class 'pandas.core.series.Series'>
print("This is type(df['date_real'][0]) : {}".format(type(df["date_real"][0])))
# This is type(df['date_real'][0]): < class 'pandas._libs.tslib.Timestamp'>
df_release_detail = pd.DataFrame([df["name"], df["date_real"]])
print("This is df_release_detail) : {}".format(df_release_detail))
# This is df_release_detail):
# name MoseX GUI Preview MoseX GUI Evaluation MoseX GUI Customer
# date_real 1496880000000000000 1501027200000000000 1502236800000000000
What is the cause and what is the best practice to maintain it as intended, divided by 1e9 somewhere along the process?
Comment From: TomAugspurger
Is a database required to demonstrate the problem, or can you simplify your example a bit?
Comment From: scheung38
Thanks Tom I will edit it to make it simply to read. It is in a Python Flask app with PyMongo, just curious why for example 1496880000 became 1496880000000000000, and now using this df_release_detail dataframe I cannot parse it further as it is invalid DateTime...
Comment From: jreback
this not a pandas issue. you need to coerce prob from pymongo.