타임스탬프를 다른 시간대로 변환하려면 timestamp.tz_convert()를 사용하세요. . 시간대를 매개변수로 설정합니다. 먼저 필요한 라이브러리를 가져옵니다 -
import pandas as pd
Pandas에서 타임스탬프 개체를 만듭니다. 시간대도 설정했습니다.
timestamp = pd.Timestamp('2021-10-14T15:12:34.261811624', tz='US/Eastern')
타임스탬프의 시간대 변환
timestamp.tz_convert('Australia/Brisbane')) 예시
다음은 코드입니다.
import pandas as pd
# set the timestamp object in Pandas
# we have also set the timezone
timestamp = pd.Timestamp('2021-10-14T15:12:34.261811624', tz='US/Eastern')
# display the Timestamp
print("Timestamp...\n", timestamp)
# convert timezone
print("\nConvert the Timestamp timezone...\n",
timestamp.tz_convert('Australia/Brisbane')) 출력
그러면 다음 코드가 생성됩니다.
Timestamp... 2021-10-14 15:12:34.261811624-04:00 Convert the Timestamp timezone... 2021-10-15 05:12:34.261811624+10:00