 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Python Pandas - Convert naive Timestamp to local time zone
To convert naive Timestamp to local time zone, use the timestamp.tz_locale(). Within that, set the timezone using the tz parameter.
At first, import the required libraries −
import pandas as pd
Creating a naive timestamp
timestamp = pd.Timestamp('2021-09-14T15:12:34.261811624')  Add the timezone
timestamp.tz_localize(tz='Australia/Brisbane')
Example
Following is the code
 import pandas as pd # creating a naive timestamp timestamp = pd.Timestamp('2021-09-14T15:12:34.261811624') # display the Timestamp print("Timestamp...\n", timestamp) # add a timezone print("\nTimestamp to local time zone...\n", timestamp.tz_localize(tz='Australia/Brisbane'))  Output
This will produce the following code
Timestamp... 2021-09-14 15:12:34.261811624 Timestamp to local time zone... 2021-09-14 15:12:34.261811624+10:00
Advertisements
 