Is there a way to extract month from a given time range, and apply it to prices based on that range? Maybe best to illustrate by example. I have a range of prices with an offer start and end dates:
d = {'Price': [12, 11, 14], 'Offer_From': ['2019-10-12', '2019-10-13', '2020-02-01'],'Offer_To': ['2019-12-31', '2019-10-31', '2020-05-31'], }
df = pd.DataFrame(data=d)
df
Price Offer_From Offer_To
0 12 2019-10-12 2019-12-31
1 11 2019-10-13 2019-10-31
2 14 2020-02-01 2020-05-31
What I want is a table similar to the below, where month names are extracted from the time range:
d2 = {'Price': [12,12,12,11,14,14,14,14], 'Month': ['2019-10', '2019-11', '2019-12', '2019-10', '2020-02', '2020-03', '2020-04', '2020-05']}
df2 = pd.DataFrame(data=d2)
df2
Price Month
0 12 2019-10
1 12 2019-11
2 12 2019-12
3 11 2019-10
4 14 2020-02
5 14 2020-03
6 14 2020-04
7 14 2020-05