- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Pandas - Convert a Timestamp object to a native Python datetime object
To convert a Timestamp object to a native Python datetime object, use the timestamp.to_pydatetime() method.
At first, import the required libraries −
import pandas as pd
Create the timestamp object in Pandas
timestamp = pd.Timestamp('2021-09-11T13:12:34.261811')
Convert timestamp to native Python datetime object
timestamp.to_pydatetime()
Example
Following is the code
import pandas as pd # set the timestamp object in Pandas timestamp = pd.Timestamp('2021-09-11T13:12:34.261811') # display the Timestamp print("Timestamp...\n", timestamp) # convert timestamp to native Python datetime object print("\nConvert Timestamp...\n", timestamp.to_pydatetime())
Output
This will produce the following code
Timestamp... 2021-09-11 13:12:34.261811 Convert Timestamp... 2021-09-11 13:12:34.261811
- Related Articles
- Python Pandas - Convert PeriodIndex object to Timestamp
- How to convert timestamp string to datetime object in Python?
- Python Pandas - Convert PeriodIndex object to Timestamp and set the frequency
- Convert a pandas Timedelta object into a Python timedelta object
- How do I convert a datetime to a UTC timestamp in Python?
- Python Pandas - Construct a naive UTC datetime from a POSIX timestamp
- Python - Get the weekday from Timestamp object in Pandas
- Python Pandas - Return the Period object as a timestamp with monthly frequency
- Python Pandas - Return the Period object as a timestamp with minutely frequency
- Python Pandas - Return the Period object as a timestamp with daily frequency
- Python Pandas - Return the Period object as a timestamp with yearly frequency
- Python Pandas - Return the Timestamp representation of the Period object
- Python Pandas - Convert given Timestamp to Period
- How to convert a timestamp object in to Date in JDBC program?
- How to convert a Date object in to Timestamp in JDBC program?

Advertisements