Closed ezmiller closed 3 years ago
@ezmiller that all looks wonderful and so elegant to me.
One small thought: I think the function times-series
that is used in the tests actually creates something different (a "time index" maybe)?
@ezmiller that all looks wonderful and so elegant to me.
One small thought: I think the function
times-series
that is used in the tests actually creates something different (a "time index" maybe)?
@daslu I updated the name.
This looks great to me. Really well designed and carefully coded. There are some auto-detection routines for datatype that rely on converting the first element. All I might add to that is you may want to convert the first non-missing element; what if your first element is a missing/null value?
This looks great to me. Really well designed and carefully coded. There are some auto-detection routines for datatype that rely on converting the first element. All I might add to that is you may want to convert the first non-missing element; what if your first element is a missing/null value?
@cnuernber Thanks for making this point. I had not thought of that!
Goal
Add (partial!) support for what Pandas calls "resampling", i.e. changing the frequency or interval of data.
Solution
This PR tries to solve this by adding a function:
This function is the lowest level function. As with others, we will likely ultimate not ask users to supply the name of the index column but figure some of that our for them.
Nevertheless, Intended usage of this function is something like:
The
adjust-interval
function is really just a thin layer over a group-by operation. It encapsulates two steps: 1) Using the suppliedtime-converter
to generate a new data column and adding that to the dataset; 2) running a group-by on that new column as well as the columns specified inkeys
.Most of the "adjustment" here is actually performed by the new functions provided in the
tablecloth.time.api.converters
namespace. The functions that in this namespace that are useful foradjust-interval
, such as->minutes
, essentially take a datetime and return a new time reflecting the desired adjustment. We can think of these functions as "bucketing" the times in a column into the newly desired interval. Please take a look at the tests to get a better sense of how they transform time.One of the more interesting of these functions is
->every
that can be used to achieve more customized intervals. Eg..:Work remaining