0

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?

cs95
  • 379,657
  • 97
  • 704
  • 746

1 Answers1

0

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
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252