I need to convert TimeStamp entry to simple dd mm yyyy format in a dataframe as I need to apply GroupBy at some later stage. Issue is, the format is simply not applying. My code is
from __future__ import division
import urllib.request
import csv
import pandas as pd
import datetime as dt
def changeFormat(inputFormat):
return pd.to_datetime(inputFormat, format='%Y%m%d')
df = pd.read_excel('Incidents.xlsx',encoding='ISO-8859-1')
df = df.sort_values('REGISTERED_DT#CST')
##df.info()
columnsToExt = ['REGISTERED_DT#CST', 'PRIORITY']
df1 = pd.DataFrame(df, columns=columnsToExt)
df1['REGISTERED_DT#CST'] = df1['REGISTERED_DT#CST'].apply(lambda x: changeFormat(x))
##by_date = df1.groupby('REGISTERED_DT#CST')
print(df1.head())
My output is still the same as if function never got applied to it:
REGISTERED_DT#CST PRIORITY
0 2015-06-01 00:22:17 5
1 2015-06-01 06:42:27 4
2 2015-06-01 06:42:59 5
3 2015-06-01 07:00:03 5
4 2015-06-01 07:15:04 4
>>>
I want it in below format:
REGISTERED_DT#CST PRIORITY
0 2015-06-01 5
1 2015-06-01 4
2 2015-06-01 5
3 2015-06-01 5
4 2015-06-01 4
>>>