# import necessary libraries
import time
import pandas as pd
# create a time series
time_series = pd.Series(["2022-01-10", "2022-02-15", "2022-03-23",
"2022-04-09", "2022-05-19","2022-06-30"])
# get day of month
day_of_month = time_series.apply(lambda x:
time.strptime(x, '%Y-%m-%d').tm_mday)
# get week number
week_number = time_series.apply(lambda x:
time.strptime(x, '%Y-%m-%d').tm_yday // 7 + 1)
# day of year
day_of_year = time_series.apply(lambda x:
time.strptime(x, '%Y-%m-%d').tm_yday)
# compile all series in a dataframe
df = pd.DataFrame({'date': time_series,
'day_of_month': day_of_month,
'week_number': week_number,
'day_of_year': day_of_year})
# print the dataframe
print(df)