[Python] Display local Kolkata Date and Time in a DataFrame column using Pandas in Python

Discussão em 'Python' iniciado por Stack, Junho 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am new to python and pandas library and not able to find solution to this simple problem. I am totally stuck at this point. I have a dataframe that contains a 'timestamp' column (datatype is datetime64[ns, 'Asia/Kolkata']. Originally the data in 'timestamp' column was in in64 format (1748174400000, 1748188800000 etc..)

    I converted this column in dataframe to Datetime Aware column using the below command:

    df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms', utc = True)


    Output was --

    (2025-05-25 12:00:00+00:00, 2025-05-25 16:00:00+00:00 etc..)


    Then I converted the timezone to 'Asia/Kolkata' using the below command:

    df['timestamp'] = df['timestamp'].dt.tz_convert('Asia/Kolkata')


    Output was --

    (2025-05-25 17:30:00+05:30, 2025-05-25 21:30:00+05:30 etc..)


    I want to convert the 'timestamp' column values to the actual local date and time of Kolkata instead of +05:30 added to UTC. How can I achieve this??

    Continue reading...

Compartilhe esta Página