python - Converting a Datetime column back to an Object -


i have column of dates converted datetime64[ns] using

 dftest['date'] = pd.to_datetime(dftest['date']) 

now want convert datetime object, can concatenate string. best way this?

you call apply , use datetime.strptime:

in [37]:  df = pd.dataframe(['05/06/2015 00:00', '22/06/2015 00:00'], columns=['date']) df['date']= pd.to_datetime(df['date']) df out[37]:         date 0 2015-05-06 1 2015-06-22  in [38]:  df['date'] = df['date'].apply(lambda x: dt.datetime.strftime(x,'%y-%m-%d')) df out[38]:          date 0  2015-05-06 1  2015-06-22 in [39]:  df.info() <class 'pandas.core.frame.dataframe'> int64index: 2 entries, 0 1 data columns (total 1 columns): date    2 non-null object dtypes: object(1) memory usage: 32.0+ bytes