Dec-09-2022, 05:23 AM
Hi
I want to resample to obtain all the values of the last week of the month. However, there are some weeks that overlap between 2 months. For Python, it would ignore such weeks if I use the below code:
Eg for Jan, the code take "27-Jan-89" as the last week of the month. But in reality, the week "3-Feb-89" also has days of Jan so I want the value 2 instead.
Thank you.
Initial DF:
20-Jan-89 3
27-Jan-89 4
3-Feb-89 2
10-Feb-89 5
17-Feb-89 3
24-Feb-89 5
3-Mar-89 5
10-Mar-89 6
17-Mar-89 4
24-Mar-89 5
31-Mar-89 7
7-Apr-89 6
14-Apr-89 6
21-Apr-89 4
28-Apr-89 7
5-May-89 5
12-May-89 6
19-May-89 5
26-May-89 7
2-Jun-89 7
Output from code:
1989-01-31 4
1989-02-28 5
1989-03-31 7
1989-04-30 7
1989-05-31 7
1989-06-30 7
DESIRED OUTPUT
Jan Feb Mar Apr May
1989 1989 1989 1989 1989
2.00 5.00 7.00 5.00 7.00
I want to resample to obtain all the values of the last week of the month. However, there are some weeks that overlap between 2 months. For Python, it would ignore such weeks if I use the below code:
1 |
m0_2 = q0.resample( 'M' ).last() |
Thank you.
Initial DF:
20-Jan-89 3
27-Jan-89 4
3-Feb-89 2
10-Feb-89 5
17-Feb-89 3
24-Feb-89 5
3-Mar-89 5
10-Mar-89 6
17-Mar-89 4
24-Mar-89 5
31-Mar-89 7
7-Apr-89 6
14-Apr-89 6
21-Apr-89 4
28-Apr-89 7
5-May-89 5
12-May-89 6
19-May-89 5
26-May-89 7
2-Jun-89 7
Output from code:
1989-01-31 4
1989-02-28 5
1989-03-31 7
1989-04-30 7
1989-05-31 7
1989-06-30 7
DESIRED OUTPUT
Jan Feb Mar Apr May
1989 1989 1989 1989 1989
2.00 5.00 7.00 5.00 7.00