I have a excel sheet, which i am reading using Python. There's a date column, where the data is in below format:
2017/10/02 13:51:39 BST
2017/11/08 19:55:11 GMT
I need to convert the data to GMT format itself. Any ways to do so?
I have a excel sheet, which i am reading using Python. There's a date column, where the data is in below format:
2017/10/02 13:51:39 BST
2017/11/08 19:55:11 GMT
I need to convert the data to GMT format itself. Any ways to do so?
I think you need replace
by dict
with to_datetime
:
df = pd.DataFrame({'date': ['2017/10/02 13:51:39 BST', '2017/11/08 19:55:11 GMT']})
d = {'BST':'+0100', 'GMT':'+0000'}
df['date'] = pd.to_datetime(df['date'].replace(d, regex=True))
print (df)
date
0 2017-10-02 12:51:39
1 2017-11-08 19:55:11