After struggling for a few weeks, I have accumulated a few examples of challenging date-related operatations with datasets. Some I have partial solutions; others I cannot yet do. The resources on Datetime objects in datasets is thin on here (both are relatively new to Mathematica, so no surprise), so maybe this will fill in that gap.
For all of my data, we have events that occur at a datetime. We want to understand how the progress on given days compare; for example, when did task A occur on April 4, 2017 vs October 12, 2018? What is the distribution for Task A occurring throughout a day over 100 days?
How can I plot a
DateHistogram
with a bin of, say, 20 minutes? I can do it by hour:DateHistogram[dataset, "Hour", DateReduction->"Day"]
How can I utilize the
DateHistogram
plot style using the operator form? A relatively new functionality allows the syntaxdataset[plotstyle,"Key"]
(see this nice StackExchange thread). For example, I can implement:dataset[Groupby[Key["State"]] /* (PieChart[#, ChartLabels->Keys[#]]&), Length]
I want to use this syntax with
DateHistogram
; I can implement the most basic version:dataset[DateHistogram,"Sent"]
I want to add the
DateReduction
option, along the lines of:dataset[DateHistogram["Hour",DateReduction->"Day"],"Sent"]
Unfortunately, the above example doesn't work and I can't find more documentation.
How can I select objects in a certain time window? I figured out a method, but perhaps there is a more elegant solution. In the below example, I can plot the events that occur before 2016:
eventsBefore2016 = dataset[Select[#Sent<DateObject[{2016,1,1}]&,"Sent"];
DateHistogram[eventsBefore2016,"Hour",DateReduction->"Day"]
Can I make these two lines into one line of code, for example? Could I do it using the operate form (question 2)?
How can I adapt a
DistributionChart
for a dataset of Datetime values? I don't example starter code for this one.
(Apologies for the generic code examples below; I can't share the actual data and my workplace blocks the tutorial datasets such as titanic. If this is a real sticking issue I can adapt this question with a tutorial dataset later at home.)