

- 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 - Get the weekmask applied on the CustomBusinessHour offset
<p>To get the weekmask applied on the CustomBusinessHour offset, use the CustomBusinessHour.weekmask property in Pandas.</p><p>At first, import the required libraries −</p><pre class="just-code notranslate language-python3" data-lang="python3">import pandas as pd</pre><p>Set the timestamp object in Pandas −</p><pre class="just-code notranslate language-python3" data-lang="python3">timestamp = pd.Timestamp('2021-11-14 05:20:30') </pre><p>Create the CustomBusinessHour Offset. CustomBusinessHour is the DateOffset subclass. Weekmask of valid business days −</p><pre class="just-code notranslate language-python3" data-lang="python3">cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 7, weekmask = 'Mon Tue Wed Fri')</pre><p>Add the offset to the Timestamp and display the Updated Timestamp −</p><pre class="just-code notranslate language-python3" data-lang="python3">print(" Updated Timestamp... ",timestamp + cbhOffset) </pre><p>Display the weekmask −</p><pre class="just-code notranslate language-python3" data-lang="python3">print(" The weekmask on the CustomBusinessHour object.. ", cbhOffset.weekmask)</pre><h2>Example</h2><p>Following is the code −</p><pre class="demo-code notranslate language-python3" data-lang="python3">import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-11-14 05:20:30') # Display the Timestamp print("Timestamp... ",timestamp) # Create the CustomBusinessHour Offset # CustomBusinessHour is the DateOffset subclass # Weekmask of valid business days cbhOffset = pd.tseries.offsets.CustomBusinessHour(n = 7, weekmask = 'Mon Tue Wed Fri') # Display the CustomBusinessHour Offset print(" CustomBusinessHour Offset... ",cbhOffset) # Add the offset to the Timestamp and display the Updated Timestamp print(" Updated Timestamp... ",timestamp + cbhOffset) # Return frequency applied on the given CustomBusinessHour Offset object as a string print(" Frequency applied on the given CustomBusinessHour Offset object... ",cbhOffset.freqstr) # display the weekmask print(" The weekmask on the CustomBusinessHour object.. ", cbhOffset.weekmask)</pre><h2>Output</h2><p>This will produce the following code −</p><pre class="result notranslate">Timestamp... 2021-11-14 05:20:30 CustomBusinessHour Offset... <7 * CustomBusinessHours: CBH=09:00-17:00> Updated Timestamp... 2021-11-15 16:00:00 Frequency applied on the given CustomBusinessHour Offset object... 7CBH The weekmask on the CustomBusinessHour object.. Mon Tue Wed Fri</pre>
- Related Questions & Answers
- Python Pandas - Get the weekmask applied on the CustomBusinessDay offset
- Python Pandas - Return the count of increments applied on the CustomBusinessHour offset
- Python Pandas - Return the name of the frequency applied on the given CustomBusinessHour offset object
- Python Pandas - Return frequency applied on the given CustomBusinessHour Offset object as a string
- Python Pandas - Display the keyword arguments applied on the given CustomBusinessHour object
- Python Pandas - Return the rule code applied on the given CustomBusinessHour 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 - Create a CustomBusinessHour Offset object
- Python Pandas CustomBusinessHour - Check if the given timestamp is on offset or not
- Python Pandas - Return the name of the frequency that is applied on the offset object
- 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
Advertisements