 
  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 - Return the Timestamp representation of the Period object
To return the Timestamp representation of the Period object, use the period.to_timestamp() method.
At first, import the required libraries −
import pandas as pd
The pandas.Period represents a period of time. Creating a Period object
period = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 17, minute = 20, second = 45)
Display the Period object
print("Period...\n", period)  Return the Timestamp representation of the Period object. We have set the frequency using the "freq" parameter
print("\nPeriod to Timestamp...\n", period.to_timestamp(freq='T')) Example
Following is the code
 import pandas as pd # The pandas.Period represents a period of time # Creating a Period object period = pd.Period(freq="S", year = 2021, month = 9, day = 18, hour = 17, minute = 20, second = 45) # display the Period object print("Period...\n", period) # Return the Timestamp representation of the Period object # We have set the frequency using the "freq" parameter print("\nPeriod to Timestamp...\n", period.to_timestamp(freq='T'))  Output
This will produce the following code
Period... 2021-09-18 17:20:45 Period to Timestamp... 2021-09-18 17:20:00
Advertisements
 