
- 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 frequency applied on the given BusinessDay Offset object as a string
To return frequency applied on the given BusinessDay Offset object as a string, use the BusinessDay.freqstr property in Pandas.
At first, import the required libraries −
import datetime import pandas as pd
Set the timestamp object in Pandas −
timestamp = pd.Timestamp('2021-1-1 01:55:02.000045')
Create the BusinessDay Offset. BusinessDay is the DateOffset subclass −
bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(days = 7, hours = 7, minutes = 7))
Display the Updated Timestamp −
print("\nUpdated Timestamp...\n",timestamp + bdOffset)
Return the frequency applied on the given BusinessDay object as a string −
print("\nFrequency on the given BusinessDay Offset...\n",bdOffset.freqstr)
Example
Following is the code −
import datetime import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-1-1 01:55:02.000045') # Display the Timestamp print("Timestamp...\n",timestamp) # Create the BusinessDay Offset # BusinessDay is the DateOffset subclass bdOffset = pd.tseries.offsets.BusinessDay(offset = datetime.timedelta(days = 7, hours = 7, minutes = 7)) # Display the BusinessDay Offset print("BusinessDay Offset...\n",bdOffset) # Display the Updated Timestamp print("\nUpdated Timestamp...\n",timestamp + bdOffset) # return the frequency applied on the given BusinessDay object as a string print("\nFrequency on the given BusinessDay Offset...\n",bdOffset.freqstr)
Output
This will produce the following code −
Timestamp... 2021-01-01 01:55:02.000045 BusinessDay Offset... <BusinessDay: offset=datetime.timedelta(days=7, seconds=25620)> Updated Timestamp... 2021-01-11 09:02:02.000045 Frequency on the given BusinessDay Offset... B+7D7H7Min
- Related Articles
- Python Pandas - Return the name of the frequency applied on the given BusinessDay offset object
- 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 frequency applied on the given DateOffset object as a string
- Python Pandas - Return the rule code applied on the given BusinessDay object
- Python Pandas - Return the count of increments applied on the BusinessDay offset
- 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 the frequency applied on the given DateOffset object
- Python Pandas - Return the name of the frequency that is applied on the offset object
- Python Pandas - Display the keyword arguments applied on the given BusinessDay object
- Python Pandas - Return the string alias of the Time series frequency applied on the given Period object
- Python Pandas - Return the frequency object as a string from the PeriodIndex object

Advertisements