I have a df time series. I extracted the indexes and want to convert them each to datetime. How do you go about doing that? I tried to use pa
Assuming you are trying to convert pandas timestamp objects, you can just extract the relevant data from the timestamp:
#Create the data
data = {1: tslib.Timestamp('2013-01-03 00:00:00', tz=None), 2: tslib.Timestamp('2013-01-04 00:00:00', tz=None), 3: tslib.Timestamp('2013-01-03 00:00:00', tz=None)}
#convert to df
df = pandas.DataFrame.from_dict(data, orient = 'index')
df.columns = ['timestamp']
#generate the datetime
df['datetime'] = df['timestamp'].apply(lambda x: datetime.date(x.year,x.month,x.day))
Of course, if you need seconds, minutes, and hours, you can include those as arguments for the function datetime.datetime as well.