My recent question was not as clear as it could have been:
I'd like to rephrase it.
I have lis, a list of records. Each record consists of one (of two possible) dates, a parameter name, a numerical value, another parameter name, another numerical value, and a miscellaneous parameter name; 6 sub-elements in each element of lis, as can be seen below:
lis = {
{DateObject[{2000, 1, 1}], "a", 1, "b", 2, "w"},
{DateObject[{1999, 12, 31}], "a", 1, "b", 2, "w"},
{DateObject[{2000, 1, 1}], "a", 1, "c", 2, "w"},
{DateObject[{1999, 12, 31}], "a", 1, "c", 3, "w"},
{DateObject[{1999, 12, 31}], "b", 1, "c", 2, "w"}
}
The rules to be applied to get desired res include:
1) There are pairs of records which are identical, apart from date. With these pairs, I'd like to delete the older record and pass the newer record to res.
2) There are also pairs from different dates where the parameters are identical, but their values may be different. I will would like to pass both these pairs to res as well.
3) There will be elements with older dates where the parameter names and values will not match any of the elements with the newest date. These elements with the older dates that do not match those with newer dates should be dropped and not passed on to res.
So we have:
res = {
{DateObject[{2000, 1, 1}], "a", 1, "b", 2,"w"},
{DateObject[{2000, 1, 1}], "a", 1, "b", 3,"w"},
{DateObject[{1999, 12, 31}], "a", 1, "b", 2, "w"}
}
lis
is from2001
? Anyway, have you tried anything? $\endgroup$<|Rest[#] -> First[#] & /@ Sort[lis]|>
$\endgroup$res
should have been dropped because it exactly matches the first item aside from the date. $\endgroup$