Let consider :
- A time interval (January given by
Time
) - A random set of values (Minimal example values given by
Val
)
as
Time = Map[DateObject, DateRange[{2022, 1, 1}, {2022, 1, 31}]];
Val = RandomReal[{0, 1}, Length@Time];
If I would like to extract some data between two days of January, this can be done by using
DateSelect[Time, 20 > #Day > 1 &]
(*{{2022, 1, 2, 0, 0, 0.}, {2022, 1, 3, 0, 0, 0.}, {2022, 1, 4, 0, 0, 0.}, {2022, 1, 5, 0, 0, 0.}, {2022, 1, 6, 0, 0, 0.}, {2022, 1, 7, 0, 0, 0.}, {2022, 1, 8, 0, 0, 0.}, {2022, 1, 9, 0, 0, 0.}, {2022, 1, 10, 0, 0, 0.}, {2022, 1, 11, 0, 0, 0.}, {2022, 1, 12, 0, 0, 0.}, {2022, 1, 13, 0, 0, 0.}, {2022, 1, 14, 0, 0, 0.}, {2022, 1, 15,0, 0, 0.}, {2022, 1, 16, 0, 0, 0.}, {2022, 1, 17, 0, 0, 0.}, {2022,1, 18, 0, 0, 0.}, {2022, 1, 19, 0, 0, 0.}}*)
Now let consider the following new dataset given by
Data = Transpose@{Time, Val};
I would like to extract some data with the function DateSelect
but based on the first column of Data
. For now I've tried :
DateSelect[Data, 20 > #Day > 1 &]
FailedDateSelect[Data, 20 > #[[1]] > 1 &]
FailedDateSelect[Data, 20 > #Day[[1]] > 1 &]
Failed
A possibility would be (but less elegant in my opinion)
Select[Data, 20 > DateValue[#[[1]], "Day"] > 1 &]
Any idea to restrict to DateSelect
DateSelect
takes only a list of date objects (DateObject
,DateInterval
,DateList
,DateString
) as the first argument.So you cannot useDateSelect[Data, pred]
for anypred
to get the filtering you want. Perhaps you might find something likeSelect[Data, 20 > #[[1]]["Day"] > 1 &]
less inelegant? $\endgroup$