
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
Python Pandas - Return the name of the frequency that is applied on the offset object
To return the name of the frequency that is applied on the offset object, use the offset.name property in Pandas. At first, import the required libraries −
from pandas.tseries.frequencies import to_offset import pandas as pd
Set the timestamp object in Pandas −
timestamp = pd.Timestamp('2021-09-26 03:25:02.000045')
Create the DateOffset. We are incrementing the months here using the "M" frequency −
offset = to_offset("3M")
Display the Updated Timestamp −
print("\nUpdated Timestamp...\n",timestamp + offset)
Return the name of the frequency applied on the given DateOffset object −
print("\nThe name of the frequency on the DateOffset object..\n", offset.name)
Example
Following is the code −
from pandas.tseries.frequencies import to_offset import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-09-26 03:25:02.000045') # Display the Timestamp print("Timestamp...\n",timestamp) # Create the DateOffset # We are incrementing the months here using the "M" frequency offset = to_offset("3M") # Display the DateOffset print("\nDateOffset...\n",offset) # Display the Updated Timestamp print("\nUpdated Timestamp...\n",timestamp + offset) # return the name of the frequency applied on the given DateOffset object print("\nThe name of the frequency on the DateOffset object..\n", offset.name)
Output
This will produce the following code −
Timestamp... 2021-09-26 03:25:02.000045 DateOffset... <3 * MonthEnds> Updated Timestamp... 2021-11-30 03:25:02.000045 The name of the frequency on the DateOffset object.. M
- Related Articles
- Python Pandas - Return the name of the frequency applied on the given BusinessDay offset object
- Python Pandas - Return the name of the frequency applied on the given BusinessHour offset object
- Python Pandas - Return the name of the frequency applied on the given CustomBusinessDay offset object
- Python Pandas - Return the name of the frequency applied on the given CustomBusinessHour offset object
- Python Pandas - Return frequency applied on the given BusinessDay Offset object as a string
- Python Pandas - Return frequency applied on the given BusinessHour Offset object as a string
- Python Pandas - Return frequency applied on the given CustomBusinessDay Offset object as a string
- Python Pandas - Return frequency applied on the given CustomBusinessHour Offset object as a string
- Python Pandas - Return the frequency applied on the given DateOffset object
- Python Pandas - Return the count of increments applied on the BusinessDay offset
- Python Pandas - Return the count of increments applied on the BusinessHour offset
- Python Pandas - Return the count of increments applied on the CustomBusinessDay offset
- Python Pandas - Return the count of increments applied on the CustomBusinessHour offset
- Python Pandas - Return frequency applied on the given DateOffset object as a string
- Python Pandas - Return the string alias of the Time series frequency applied on the given Period object

Advertisements