Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG/API: Index creation with different tz coerces DatetimeIndex #11696
Conversation
sinhrks
added API Design Timezones
labels
Nov 24, 2015
sinhrks
added this to the
0.18.0
milestone
Nov 24, 2015
jreback
commented on an outdated diff
Nov 27, 2015
| @@ -1409,6 +1409,26 @@ cpdef inline object maybe_get_tz(object tz): | ||
| return tz | ||
| +cpdef is_datetime_with_singletz_array(ndarray[object] values): | ||
| + """ | ||
| + Check values have the same tzinfo attribute. | ||
| + Doesn't check values are datetime-like types. | ||
| + """ | ||
| + cdef Py_ssize_t i, n = len(values) | ||
| + cdef object base_tz, tz | ||
| + | ||
| + if n == 0: | ||
| + return False | ||
| + | ||
| + base_tz = getattr(values[0], 'tzinfo', None) | ||
| + base_tz = get_timezone(base_tz) |
|
|
jreback
commented on an outdated diff
Nov 27, 2015
| + """ | ||
| + Check values have the same tzinfo attribute. | ||
| + Doesn't check values are datetime-like types. | ||
| + """ | ||
| + cdef Py_ssize_t i, n = len(values) | ||
| + cdef object base_tz, tz | ||
| + | ||
| + if n == 0: | ||
| + return False | ||
| + | ||
| + base_tz = getattr(values[0], 'tzinfo', None) | ||
| + base_tz = get_timezone(base_tz) | ||
| + | ||
| + for i in range(1, n): | ||
| + tz = getattr(values[i], 'tzinfo', None) | ||
| + if base_tz != get_timezone(tz): |
|
|
jreback
and 1 other
commented on an outdated diff
Nov 27, 2015
| + Doesn't check values are datetime-like types. | ||
| + """ | ||
| + cdef Py_ssize_t i, n = len(values) | ||
| + cdef object base_tz, tz | ||
| + | ||
| + if n == 0: | ||
| + return False | ||
| + | ||
| + base_tz = getattr(values[0], 'tzinfo', None) | ||
| + base_tz = get_timezone(base_tz) | ||
| + | ||
| + for i in range(1, n): | ||
| + tz = getattr(values[i], 'tzinfo', None) | ||
| + if base_tz != get_timezone(tz): | ||
| + return False | ||
| + return True |
jreback
Contributor
|
|
Thanks, moved to |
|
lgtm. comment above. |
|
Thanks, I've fixed the tz comparison logic based on your comment below.
|
|
merged via b80b5c7 thanks! |
sinhrks commentedNov 24, 2015
Closes #11488.
Based on the type check added in #11588, the change affects to fewer functions than I originally thought.