

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Python Pandas - Return the Period object as a timestamp with minutely frequency
To return the Period object as a timestamp with monthly frequency, use the period.to_timestamp() method and set the freq parameter as ‘T’.
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 = 11, day = 26, hour = 11, minute = 45, second = 55)
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. The frequency is set as 'T' i.e. minutely
print("\nPeriod to Timestamp with minutely frequency...\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 = 11, day = 26, hour = 11, minute = 45, second = 55) # 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 # The frequency is set as 'T' i.e. monthly print("\nPeriod to Timestamp with minutely frequency...\n", period.to_timestamp(freq='T'))
Output
This will produce the following code
Period... 2021-11-26 11:45:55 Period to Timestamp with minutely frequency... 2021-11-26 11:45:00
- Related Questions & Answers
- Python Pandas - Return the Period object as a timestamp with monthly 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 - Convert given Timestamp to Period with minutely frequency
- Python Pandas - Change the frequency of the given Period object from Seconds to Minutely frequency
- Python Pandas - Return the Timestamp representation of the Period object
- Python Pandas - Convert given Timestamp to Period with weekly frequency
- Python Pandas - Convert given Timestamp to Period with monthly frequency
- Python Pandas - Convert given Timestamp to Period with quarterly frequency
- Python Pandas - Convert given Timestamp to Period with hourly frequency
- Python Pandas - Round the Timedelta with minutely frequency
- Python Pandas - Return the frequency object as a string from the PeriodIndex object
- Python Pandas - Perform ceil operation on the TimeDeltaIndex object with minutely frequency
- Python Pandas - Get the frequency for the given Period object
- Python Pandas - Return frequency applied on the given DateOffset object as a string
Advertisements