Change language

Python | Pandas tseries.offsets.BusinessDay.name

| | |

DateOffsets can be created to move dates by a specified number of valid dates. For example, Bday (2) can be added to a date to move it two business days forward. If the date does not start with a valid date, it is first moved to a valid date and then an offset is generated.

tseries.offsets.BusinessDay.name Pandas tseries.offsets.BusinessDay.name allows you to use offset in functions for simplicity instead of importing and initializing the class. It also returns the name of the frequency that is applied to the offset object.

Syntax: pandas.tseries.offsets.BusinessDay.name

Parameter: None

Returns: name

Example # 1: Use the pandas.tseries.offsets.BusinessDay.name to return the name of the frequency applied to this offset object.

# import pandas as pd

import pandas as pd

 
# Create a timestamp

ts = pd.Timestamp ( ’2019-10-10 07: 15: 11’ )

  
# Create offset 5 business days

bd = pd.tseries.offsets.BusinessDay (n = 5 )

 
# Time stamp printing

print (ts)

 
# Print DateOffset

print (bd)

Output:

Now we will add the workday offset to this timestamp object to increase the date value time. We will also print the name of the frequency applied to this offset object.

# Add a workday offset to this timestamp

new_timestamp = ts + bd

 
# Print updated timestamp

print (new_timestamp)

 
# Print the name of the applied frequency
# on the given offset object

print (bd.name)

Output: < / p>

As we can see from the output, we have successfully created an offset of 5 business days and added it to the given timestamp. We also printed the name of the frequency applied to this offset object.

Example # 2: Use the pandas.tseries.offsets.BusinessDay.name attribute to return the name of the frequency applied to this offset object.

# import pandas as pd

import pandas as pd

 
# Create a timestamp

ts = pd.Timestamp ( ’ 2019-10-10 07: 15: 11’ )

 
# Create an offset of 10 business days and 10 hours

bd = pd.tseries.offsets.BusinessDay (offset = datetime.timedelta (days = 10 , hours = 10 ))

 
# Print time stamp

print (ts)

 
# Print DateOffset

print (bd)

Output:

Now we will add the workday offset to this timestamp object so that increase the datetime value. We will also print the name of the frequency applied to this offset object.

# Add a workday offset to this timestamp

new_timestamp = ts + bd

 
# Print updated timestamp

print (new_timestamp)

 
# Print the name of the applied frequency
# on the given offset object

print (bd.name)

Output: < / p>

As we can see from the output, we have successfully created an offset of 10 business days and 10 hours and added it to the given time stamp. We’ve also printed the name of the frequency applied to this offset object.

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method