-
-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slicing and Sampling in Time-Dimensions #886
Comments
I believe there are three places we'd need the implementation:
All three could probably share one utility however. |
@mrksr Thanks for the nicely laid out proposal - it looks good to me! A few quick comments:
I also agree with Philipp that if this functionality can be encapsulated within a single utility, we should do that. |
We can check whether the data type is of type |
I agree we are relying on pandas more and more so that proposal seems reasonable to me, especially if pandas can do most of the hard work for us. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Problem statement
It is quite common for scientific data to consist of series for which on key dimension is time. To represent specific points in time, numpy supports a dtype called
datetime64
. Holoviews can handle datasets which contain time information. However, slicing and sampling in these dimensions is tricky. Consider the following data set which contains samples for every fifteen minutes of a day.Using the pandas dataframe directly, time ranges can be selected using normal slicing.
This requires some code specific to time stamps which converts the date strings to the correct data type.
Slicing in Holoviews
Given two
numpy.datetime64
-objectsdate_from
anddate_to
, slicing of the Holoviews dataset works as usual.There are multiple ways of creating such objects, the most convenient one being the the pandas API.
Slicing using pandas
The pandas timeseries API offers the
pd.Timestamp
-object, which can be constructed from different time descriptions such as strings ordatetime
-objects from the standard library. Timestamps can then be converted to datetime64.Using Timestamp introduces a dependency to pandas however.
Slicing using numpy
datetime64-objects can be constructed using numpy directly.
The constructor however seems to be limited to ISO-8601 datestrings and datetime objects. The latter could be used to allow for more liberal date descriptions using
strptime
. It is worth noting that while the datetime64-objects of numpy have nanosecond accuracy, to my understanding, the datetime-objects from the standard library only have microsecond accuracy.Proposed changes
Since
datetime
has a nice string representation, output of time dimensions works nicely out of the box. Things only become tricky when specifying a specific time to do sampling and slicing in a holoviews dataset. Ideally, the syntax would be similar to the way pandas handles things in the sense that everywhere I would need to specify a datetime64-object, I can also give some representation of a time stamp which can be parsed to a datetime64-object. So instead ofI would like to be able to just specify
The text was updated successfully, but these errors were encountered: