I have a dataset with timestamps in the format:
`'4/17/2020 5:55:00 AM'`
Please note there are 2 spaces between YYYY and HH fields. The original time is in 'US/Eastern' timezone. I am trying to convert it to IST (Indian Standard Time). This should be 'Asia/Kolkata' from pytz
The code below is not working, and I have tried multiple versions of it. Even conversion to UTC is failing. The code block is:
`
est_ts = '4/17/2020 5:55:00 AM'
est = pytz.timezone('US/Eastern')
ist = pytz.timezone('Asia/Kolkata')
print(dt.datetime.strptime(est_ts, '%m/%d/%Y %I:%M:%S %p').astimezone(ist).strftime('%Y-%m-%d %H:%M:%S'))
`
This gives an output of:
`2020-04-17 07:25:00`
While the correct output should be:
`2020-04-17 15:25:00`
What is wrong with this code? Much appreciated.
localize()method is the way to go, see drec4s answer below. See here on why you should alsonormalize().