How to group by item and date, then for each sub-dataframe, get the actual row where 'data' value is the actual middle value in the sub-dataframe?
Sometimes there are multiple rows where data equals the middle value, in this case we only keep the first row.
df:
item date data
0 22 2012-03-10 10
1 22 2012-03-10 20
2 22 2012-03-10 40
3 24 2012-03-11 40
4 24 2012-03-11 50
5 24 2012-03-11 50
expected output:
1 22 2012-03-10 20
4 24 2012-03-11 50