
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Timestamp to Another Time Zone in Python Pandas
Convert Timestamp to another time zone, use the timestamp.tz_convert(). Set the time zone as the parameter. At first, import the required libraries −
import pandas as pd
Create the timestamp object in Pandas. We have also set the timezone
timestamp = pd.Timestamp('2021-10-14T15:12:34.261811624', tz='US/Eastern')
Convert timezone of timestamp
timestamp.tz_convert('Australia/Brisbane'))
Example
Following is the code
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'))
Output
This will produce the following code
Timestamp... 2021-10-14 15:12:34.261811624-04:00 Convert the Timestamp timezone... 2021-10-15 05:12:34.261811624+10:00
Advertisements