'Use existing datetime data to create Week tags and week numbers
I have the following code which creates a range of dates from 1st Jan 2021. This runs until 15th May 2022.
import pandas as pd
range = pd.date_range('2021-01-01', periods=500, freq='D')
df = pd.DataFrame({ 'Date': range})
df.head()
I would like to use the current datetime data to create another column which provides tags for weeks that are counted from every Thursday to Friday. This will be considered as 1 week count.
For example, the column should list date, month and year for each row of the matching 'range' column. This can be like: 10.03.21 to 18.03.21, for 10th March to 18th March (repeated for all rows for date ranges where it falls in range for Thursday to Friday each week).
Basically, my requirements for one week starts from Thursday, and ends the following week Friday.
For each week completion, another column should indicate the count, for e.g Week 1, Week 2 and etc.
How can this be achieved using Pandas datetime function, to easily produce another column with tagging for week categorisation ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
