How to convert the timezone of the API data result from UTC to IST?

For an external client, she is using the below code to get historical data using Phyton from EIkon

ek.set_app_key('***')

data=ek.get_timeseries('SBI.NS', interval='tick')

data.tail(10)


output

SBI.NS VALUE VOLUME

Date

2021-07-09 10:20:09.000 423.75 6

2021-07-09 10:20:21.000 423.75 10

2021-07-09 10:20:24.000 423.75 15

2021-07-09 10:20:37.000 423.75 1

2021-07-09 10:20:44.000 423.75 300

2021-07-09 10:21:39.000 423.75 1

2021-07-09 10:26:15.000 423.75 1


The timestamp is in UTC. She would like to know if there is a way she can get the timestamp of the results in IST.

Best Answer

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭
    Answer ✓

    @jonathan.legrand

    The pythonic way is to utilize vectorized methods wherever possible instead of your own loops. The main reason is that vectorized methods are optimized for runtime and typically run faster than your own loops (sometimes by an order of magnitude faster). Vectorized methods also improve readability of the code by making the code more compact.

    @jaredd.matutina01

    Please see an example of of converting the timezone in the dataframe index from UTC to the timezone of your choice on this thread.

Answers