Description
The functions for DataFrame, "between_time" and "at_time" are unfortunately not time zone aware.
I suggest adding a timezone parameter to these functions to clearly specify which time zone the requested time belongs to. The sampler should take into account the time zone of data frame, and the supplied time zone.
It will also be interesting to be able to sample at a specific time both daylight savings adjustment aware and agnostic. For example it will be interesting to sample at every 09:00 New York time (whether it is summer time or winter time, and irrespective of how we stored the time in our dataframe). For this a time zone parameter will not be sufficient, a time zone history will need to be supplied.
Time zone history for a specific city can be obtained by the user and supplied to the function:
https://www.timeanddate.com/time/zone/usa/new-york
Activity
gfyoung commentedon Dec 2, 2018
@cozgenc : Thanks for reporting this! Could you provide an example to illustrate the concern that you bring up in the first line?
cc @mroeschke
mroeschke commentedon Dec 3, 2018
between_time
andat_time
already function when the index is tz-aware (the specified times are local to that timezone). I'm also not clear of the primary concern.flyjuice commentedon Dec 3, 2018
Please tell me how you will be able to get the rows for US/Eastern 09:00am, if the dataframe time zone is set to Europe/Berlin for example without actually accounting for time difference?
You are simply creating dependency between the code that prepared the dataframe, and the code that consumes the dataframe. If you add timezone parameter to these functions you may explicitly specify which time you are talking about. Time without a timezone doesn't represent a universal point in time.
mroeschke commentedon Dec 3, 2018
When using
at_time
andbetween_time
, specified arguments are assumed to be in the local time relative to the timezone of the DatetimeIndex. Therefore, you can usetz_convert
to switch between timezones when indexing with these methods.However, it appears that currently passing
datetime.time
objects withtzinfo
are not supported yet, which would address your primary concern I believe:[-]between_time and at_time[/-][+]ENH: Support datetime.time objects with tzinfo in between_time and at_time[/+]