I have a multi-index pandas dataframe (groupbydataframe) as below:
Store Year Month
1 2013 1 4922.0
2 5315.5
3 5603.0
4 4625.0
5 4995.0
6 4407.0
7 4421.0
8 4494.0
9 4212.0
10 4148.5
11 5033.5
12 6111.0
2014 1 4547.5
2 4726.5
3 4455.0
4 4577.5
5 4909.0
6 4788.0
7 4507.0
8 4124.0
9 3970.5
10 4431.0
11 5220.0
12 6466.0
2015 1 4690.0
2 4467.5
3 4294.5
4 4256.0
5 4529.0
6 4102.0
...
1112 2013 2 10991.0
3 12322.0
4 10705.0
5 12096.0
6 11029.0
7 10419.0
8 8994.0
9 9448.0
10 9019.0
11 9294.0
12 11163.0
2014 1 8156.5
2 8862.5
3 8606.5
4 9662.0
5 10375.0
6 8755.0
7 8262.0
8 8454.0
9 7621.5
10 8779.0
11 9638.0
12 9592.0
2015 1 9345.0
2 8466.5
3 8457.0
4 8715.0
5 9125.0
6 8528.0
7 7728.0
The last column is "Sales".
- If
FindYear=2014andFindMonth=01how do I extract sales for2013-12to2014-02forStore=1? - if
FindYearandFindMonthare lists withlength(FindYear)=length(Store). How do do (1) without looping through all stores individually? - Or am I looking at this the wrong way? do I need to
unstack()and go from there?