I think it should be a pandas failure having a pandas series (v.18.1 and 19 too), if I assign a date to the Series, the first time it is added as an int (error), the second time it is added as a date- time (right), I can not understand the reason.
For example, using this code:
import datetime as dt import pandas as pd series = pd.Series(list('abc')) date = dt.datetime(2016, 10, 30, 0, 0) series["Date_column"] =date print("The date is {} and the type is {}".format(series["Date_column"], type(series["Date_column"]))) series["Date_column"] =date print("The date is {} and the type is {}".format(series["Date_column"], type(series["Date_column"])))
Output:
The date is 1477785600000000000 and the type is <class 'int'> The date is 2016-10-30 00:00:00 and the type is <class 'datetime.datetime'>
As you can see, the first time it always sets the value as int instead of datetime.
Can someone help me? Thanks in advance, Xavi.
python pandas datetime series
bracana
source share