

- 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 - Display the keyword arguments applied on the given BusinessHour object
<p>To display the keyword arguments applied on the given BusinessHour object, use the BusinessHour.kwds 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>Create the BusinessHour Offset. Here, "start" is the start time of your custom business hour in 24h format. The "end" is the end time of your custom business hour in 24h format −</p><pre class="just-code notranslate language-python3" data-lang="python3">bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00") </pre><p>Set the timestamp object in Pandas −</p><pre class="just-code notranslate language-python3" data-lang="python3">timestamp = pd.Timestamp('2021-1-1 01:55:30')</pre><p>Display the Updated Timestamp −</p><pre class="just-code notranslate language-python3" data-lang="python3">print(" Updated Timestamp... ",timestamp + bhOffset) </pre><p>Display the keyword arguments −</p><pre class="just-code notranslate language-python3" data-lang="python3">print(" Keyword arguments on the given BusinessHour Offset... ",bhOffset.kwds)</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-1-1 01:55:30') # Display the Timestamp print("Timestamp... ",timestamp) # Create the BusinessHour Offset # BusinessHour is the DateOffset subclass # Here, "start" is the start time of your custom business hour in 24h format. # The "end" is the end time of your custom business hour in 24h format. bhOffset = pd.tseries.offsets.BusinessHour(start="09:30", end = "18:00") # Display the BusinessHour Offset print(" BusinessHour Offset... ",bhOffset) # Display the Updated Timestamp print(" Updated Timestamp... ",timestamp + bhOffset) # Return frequency applied on the given BusinessHour Offset object as a string print(" Frequency applied on the given BusinessHour Offset object... ",bhOffset.freqstr) # Display the keyword arguments print(" Keyword arguments on the given BusinessHour Offset... ",bhOffset.kwds)</pre><h2>Output</h2><p>This will produce the following code −</p><pre class="result notranslate">Timestamp... 2021-01-01 01:55:30 BusinessHour Offset... <BusinessHour: BH=09:30-18:00> Updated Timestamp... 2021-01-01 10:30:00 Frequency applied on the given BusinessHour Offset object... BH Keyword arguments on the given BusinessHour Offset... {'start': (datetime.time(9, 30),), 'end': (datetime.time(18, 0),), 'offset': datetime.timedelta(0)}</pre>
- Related Questions & Answers
- Python Pandas - Display the keyword arguments applied on the given BusinessDay object
- Python Pandas - Display the keyword arguments applied on the given CustomBusinessDay object
- Python Pandas - Display the keyword arguments applied on the given CustomBusinessHour object
- Python Pandas - Return the rule code applied on the given BusinessHour object
- Python Pandas - Return the name of the frequency applied on the given BusinessHour offset object
- Python Pandas - Return frequency applied on the given BusinessHour 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 BusinessHour offset
- Python Pandas - Return the rule code applied on the given DateOffset object
- Python Pandas - Return the rule code applied on the given BusinessDay object
- Python Pandas - Return the rule code applied on the given CustomBusinessDay object
- Python Pandas - Return the rule code applied on the given CustomBusinessHour object
- Python Pandas - Return the count of increments applied on the given DateOffset 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 CustomBusinessDay offset object
Advertisements