-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG: Right result for DatetimeIndex + TimeDelta when timezone is set(… #13935
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -461,7 +461,7 @@ def _convert_to_array(self, values, name=None, other=None): | |
| | ||
| # a datelike | ||
| elif isinstance(values, pd.DatetimeIndex): | ||
| values = values.to_series() | ||
| values = values.to_series(True) | ||
| # datetime with tz | ||
| elif (isinstance(ovalues, datetime.datetime) and | ||
| hasattr(ovalues, 'tz')): | ||
| | @@ -543,9 +543,9 @@ def _offset(lvalues, rvalues): | |
| | ||
| # with tz, convert to UTC | ||
| if self.is_datetime64tz_lhs: | ||
| lvalues = lvalues.tz_localize(None) | ||
| lvalues = lvalues.tz_convert('UTC') | ||
| ||
| if self.is_datetime64tz_rhs: | ||
| rvalues = rvalues.tz_localize(None) | ||
| rvalues = rvalues.tz_convert('UTC') | ||
| | ||
| lvalues = lvalues.view(np.int64) | ||
| rvalues = rvalues.view(np.int64) | ||
| | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -165,7 +165,14 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None, | |
| if (issubclass(data.dtype.type, np.datetime64) or | ||
| is_datetimetz(data)): | ||
| from pandas.tseries.index import DatetimeIndex | ||
| result = DatetimeIndex(data, copy=copy, name=name, **kwargs) | ||
| if 'tz' in kwargs: | ||
| ||
| tz = kwargs['tz'] | ||
| del kwargs['tz'] | ||
| result = DatetimeIndex(data, copy=copy, tz='UTC', | ||
| name=name, **kwargs).tz_convert(tz) | ||
| else: | ||
| result = DatetimeIndex(data, copy=copy, | ||
| name=name, **kwargs) | ||
| if dtype is not None and _o_dtype == dtype: | ||
| return Index(result.to_pydatetime(), dtype=_o_dtype) | ||
| else: | ||
| | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should handle
is_datetime64_dtypeandis_datetime64tz_dtypeseparately hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it happens, isn't is?