unix_timestamp=1284105682
print(pd.to_datetime(unix_timestamp,unit='s',origin='unix'))
Expected Output : 2010-09-10 13:31:22 My Output: 2010-09-10 08:01:22
I am unable to figure out how time is getting wrong
It seems to be a UTC-related issue. You can create the datetime with UTC and then change it to your time-zone like this:
import pandas as pd
unix_timestamp=1284105682
df = pd.to_datetime(unix_timestamp, unit='s', origin='unix', utc=True)
df.tz_convert('America/Sao_Paulo')
print(pd.__version__)
Asia/Calcuttagives the expected output.tz_converttotz_convert('Asia/Kolkata')