Question: I have an intricate `Haskell` function:

```
j :: [Int]
j = ((\f x -> map x) (\y -> 3 + y) (\z -> 2*z)) [1,2,3]

```

My guess was that `(\y -> 3 + y) (\z -> 2*z)` will change to `(\w -> 3 + 2*w)` and together with `f` there should be print out the list `[5,7,9]`.

When I checked with ghci I got `[2,4,6]` as a result.

**Question**: So is `(\y -> 3 + y)` a redundant expression here? If so, why?

Answer: 
You have a sort issue to solve. One way is to do this with an intermediate dataframe:

```
df2 = pd.DataFrame([df.Date.dt.month, df.Date.dt.day]).T

df2.columns = [0,1]

df2
Out[32]: 
    0   1
0   1   1
1   1   1
2   1   2
3   1   2
4   1   1
5   1   1
6   1   2
7   1   2
8  12  31
9  12  31

df2 = df2.sort_values([0,1])

```

Now reindex `df` with the resulting index we have now in `df2`:

```
df.reindex(df2.index)
Out[36]: 
        Date Position  Value
0 2010-01-01     PEAK     60
1 2010-01-01   BOTTOM     51
4 2011-01-01     PEAK     70
5 2011-01-01   BOTTOM     61
2 2010-01-02     PEAK     62
3 2010-01-02   BOTTOM     50
6 2011-01-02     PEAK     72
7 2011-01-02   BOTTOM     60
8 2015-12-31     PEAK     92
9 2015-12-31   BOTTOM     83

```
IIUC you can do it this way:

```
In [2]: df
Out[2]:
        Date Position  Value
0 2010-01-01     PEAK     60
1 2010-01-01   BOTTOM     51
2 2010-01-02     PEAK     62
3 2010-01-02   BOTTOM     50
4 2011-01-01     PEAK     70
5 2011-01-01   BOTTOM     61
6 2011-01-02     PEAK     72
7 2011-01-02   BOTTOM     60
8 2015-12-31     PEAK     92
9 2015-12-31   BOTTOM     83

In [3]: df.groupby([df.Date.dt.month, df.Date.dt.day, 'Position']).agg(['min','mean','max','sum'])
Out[3]:
                   Value
                     min mean max  sum
Date Date Position
1    1    BOTTOM      51   56  61  112
          PEAK        60   65  70  130
     2    BOTTOM      50   55  60  110
          PEAK        62   67  72  134
12   31   BOTTOM      83   83  83   83
          PEAK        92   92  92   92

```