I'm fairly new to python so forgive me if this seems like a simple question.
I have a dataframe. My goal is to take the values of a dataframe and convert it into another type and replace that column. Here is the codes:
strtotime = {}
for x in range(0,len(results['CreationDate'])):
strtotime[x] = datetime.strptime(results['CreationDate'][x], '%Y-%m-%dT%H:%M:%S.%f')
results['CreationDate'] = pd.to_datetime(pd.Series(strtotime))
I stored the values as a dictionary, converted it to a series using pd.Series, at which point I'm fairly certain I can just replace one series with another:
i.e results['CreationDate'] = pd.to_datetime(pd.Series(strtotime))
but what I get in return for results is a column of NaT instead of these neat datetimes 2015-01-01 10:59:37.403.
I then used results['CreationDate'] = list(pd.to_datetime(pd.Series(strtotime)))
which worked perfectly as I wanted it to be. So my question is why is this the case? Does it even have anything to do with object types?